ch11virtualshapespart2.h

来自「此例子是学习C++的好东西」· C头文件 代码 · 共 41 行

H
41
字号
//Program 11-14 Virtual Shapes Part2

//File: Ch11VirtualShapesPart2.h

#ifndef  _VIRT_SHAPE2_H
#define  _VIRT_SHAPE2_H


class Shape
{
public:
	virtual void WhatAmI() =0 ;  //purely virtual, no actual function exists

};

class Pyramid:public Shape
{
public:
	void WhatAmI() { cout << "\n I am a pyramid. \n"; }
};

class Sphere : public Shape
{
public:
	void WhatAmI() { cout << "\n I am a sphere. \n"; }
};

class Cone:public Shape
{
public:
	void WhatAmI() { cout << "\n I am a cone. \n"; }
};

class Box : public Shape
{
public:
	void WhatAmI() { cout << "\n I am a box. \n"; }
};

#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?