设计一个园类circle和一个桌子类table,circle类包括私有数据成员半径radius和求圆面积得成员函数getarea():table类包含私有数据成员height(高度)和返回高度的成员函数getheight().另设计一个圆桌

设计一个园类circle和一个桌子类table,circle类包括私有数据成员半径radius和求圆面积得成员函数getarea():table类包含私有数据成员height(高度)和返回高度的成员函数getheight().另设计一个圆桌类roundtable,它是从前两个类的派生,roundtable类继承所有上述类得数据成员和成员函数,添加了私有数据成员color和相应的成员函数.要求输出一个圆桌得高度、面积和颜色等数据.
其他人气:856 ℃时间:2019-12-13 17:39:02
优质解答
class circle
{
float radius;
float area;
public:
circle(float r)
{radius=r; }
float getarea(void)
{area=3.14*radius*radius; return area;}
};
class table
{
float height;
public:
table(float h)
{height=h;}
float getheight(void)
{return height;}
};
class roundtable : public table, public circle
{
TColor color;
public:
roundtable(float h,float r,TColor c):circle(r), table(h)
{color=c;}
TColor getcolor(void)
{return color;}
};
我来回答
类似推荐
请使用1024x768 IE6.0或更高版本浏览器浏览本站点,以保证最佳阅读效果。本页提供作业小助手,一起搜作业以及作业好帮手最新版!
版权所有 CopyRight © 2012-2024 作业小助手 All Rights Reserved. 手机版