C++语言程序设计实验报告
class Circle:public Shape{
public:
Circle(float x,float y,float c):Shape(x,y),c(c){};
float GetC() {return Shape::GetX();}
float GetArea() {return GetC()*GetC()*n;}
~Circle() {};
private:
float c;
};
class Square:public Rectangle{
public:
Square(float a,float b,float d):Rectangle(a,b),d(d){}
float GetD() {return Rectangle::GetA();}
GetArea() {return GetD()*GetD();}
~Square() {};
private:
float d;
};
void main()
{
Rectangle rect(2,3);
cout<<"矩形的长为: ";
cout<<rect.GetA()<<endl;
cout<<"矩形的宽为: ";
cout<<rect.GetB()<<endl;
cout<<"面积为: ";
cout<<rect.GetArea()<<endl;
Circle cir(4,2,8);
cout<<"圆的半径为: ";
cout<<cir.GetC()<<endl;
cout<<"面积为: ";
cout<<cir.GetArea()<<endl;
Square squa(5,6,7);
cout<<"正方形的边长为:";
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库C++语言程序设计实验报告 7(2)在线全文阅读。
相关推荐: