📄 2.cpp
字号:
#include<iostream.h>
#include<string.h>
class circle
{
double radius;
public:
circle(double r) { radius=r; }
double getarea() { return radius*radius*3.14; }
};
class table
{
double height;
public:
table(double h) { height=h; }
double getheight() { return height; }
};
class roundtable : public table,public circle
{
char *color;
public:
roundtable(double h, double r, char c[]) : circle (r) , table (h)
{
color=new char[strlen(c)+1];
strcpy (color, c);
}
char *getcolor() { return color; }
};
void main()
{ roundtable rt(0.8,1.2,"黑色");
cout << "圆桌属性数据:" << endl;
cout << "高度:" <<rt.getheight() << "米" << endl;
cout << "面积:" <<rt.getarea() << "平方米" << endl;
cout << "颜色:" <<rt.getcolor() << endl;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -