*圆桌

设计一个圆类Circle和一个桌子类Table ,再设计一个圆桌类Roundtable, 它是由前两个类派生出来的,要求输出圆桌的高度、面积和颜色等数据。其中, 类Circle包含数据成员Radius(半径)和求面积的成员函数,类Table包含数据 成员height和返回高度的成员函数,类Roundtable再添加数据成员color和相应 的成员函数。

#include<iostream>  
using namespace std;  
class Circle  
{  
    protected:  
        int Radius;  
    public:  
        double area(){return 3.14*Radius*Radius;}  
};  
class Table  
{  
    protected:  
    int height;  
    public:  
        int geth(){return height;}  
};  
class Roundtable:public Circle,public Table  
{  
    char color[15];  
    public:  
        Roundtable(){cin>>Radius>>height>>color;}  
        void out()  
        {  
            cout<<"圆桌面积:"<<area()<<endl<<"圆桌的高:"<<geth()<<endl<<"圆桌的颜色:"<<color<<endl;  
        }  
};  
int main()  
{  
    Roundtable rt;  
    rt.out();  
} 

 

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值