设计一个园类circle和一个桌子类table,circle类包括私有数据成员半径radius和求圆面积得成员函数get

学习 时间:2026-04-08 01:42:58 阅读:8637
设计一个园类circle和一个桌子类table,circle类包括私有数据成员半径radius和求圆面积得成员函数getarea():table类包含私有数据成员height(高度)和返回高度的成员函数getheight().另设计一个圆桌类roundtable,它是从前两个类的派生,roundtable类继承所有上述类得数据成员和成员函数,添加了私有数据成员color和相应的成员函数.要求输出一个圆桌得高度、面积和颜色等数据.

最佳回答

鲤鱼大炮

魁梧的凉面

2026-04-08 01:42:58

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;}};

最新回答共有2条回答

  • 老实的龙猫
    回复
    2026-04-08 01:42:58

    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;}};

上一篇 谁能告诉我一些带但的成语啊~~~~~~很急~~~~

下一篇 铁原子结构铁原子核外有26个电子,则第一层为2,第二层为8,由2n^2可知第三层电子数容量为18个,但最外层电子数最多为