#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdio>
using namespace std;
class circle
{
double radius;
public:
circle(double r)
{radius=r;}
double getarea()
{
double s;
s=radius*radius*3.1415926;
return s;
}
};
class table
{
double height;
public:
table(double h)
{height=h;}
double getheight()
{return height;}
};
class roundtable:public circle,public table
{
char *color;
public:
roundtable(double a,double b,char *c=""):circle(a),table(b)
{
color=new char[strlen(c)];
strcpy(color,c);
}
char *getcolor()
{return color;}
~roundtable(){delete []color;}
roundtable(const roundtable&a){color=new char[strlen(c)];strcpy(color,a.color);};
};
int main()
{
roundtable rt(0.8,1.2,"黑色");
cout<<"圆桌属性数据:"<<endl;
cout<<"高度:"<<rt.getheight()<<"米"<<endl;
cout<<"面积:"<<rt.getarea()<<"平方米"<<endl;
cout<<"颜色:"<<rt.getcolor()<<endl;
getchar();
return 0;
}
智慧大石
函数式编程
相关分类