根据实验要求,需要定义4个类:Point、Shape、Circle、Cylinder和Triangle,并实现它们之间的继承关系。下面是对应的C++代码:

* Point类

class Point { protected: int x; int y; public: Point(int x, int y) : x(x),
y(y) {} virtual ~Point() {} virtual void show() { cout << "Point[" << x << ","
<< y << "]" << endl; } virtual string getName() { return "Point"; } };
* Shape类

class Shape { public: virtual ~Shape() {} virtual double getArea() = 0;
virtual double getPerimeter() = 0; virtual string getName() = 0; };
* Circle类

class Circle : public Point, public Shape { protected: double

技术
下载桌面版
GitHub
百度网盘(提取码:draw)
Gitee
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:ixiaoyang8@qq.com
QQ群:766591547
关注微信