求个C语言高手~~~~谢谢 急。。

来源:百度知道 编辑:UC知道 时间:2024/06/14 02:05:31
两个题选一个就行 1 采用面向对象的程序设计方法编写一个一卡通管理系统,要求使用多继承,虚函数,虚基类,要有设定类别,计算消费额等功能。2 采用面向对象的程序,圆类circle和一个桌子类table,另外设计一个圆桌类roundtable,他是从前两个类派生的,要求输出一个圆桌类的高度,面积和颜色等数据~

vc6.0
#include<iostream.h>
#include<string.h>
class circle{
public:
int r;//半径
double GetMiandi(){
return 3.14*r*r;
}
circle(int x){
r=x;
}
};
class table{
public:
int height;
char color[10];
int GetHeight(){
return height;
}
char* GetColor(){
return color;
}
table(int h,char * c){
height=h;
strcpy(color,c);
}
};
class roundtable:public circle,public table{
public:
roundtable(int r1,int h1,char* c1):circle(r1),table(h1,c1){
}
};
void main(){
roundtable roundtable1(10,20,"yellow");
cout<<"面积是:"<<roundtable1.GetMiandi()<<endl;
cout<<"高度是:"<<roundtable1.GetHeight()<<endl;
cout<<"颜色是:"<<roundtable1.GetColor()<<endl;
}