#include
class shape
{ public:
virtual float GetArea()=0;
virtual float GetPerim()=0;
};
class Rectangle:public shape
{ private:
float lenght,widht,area,perim;
public:
Rectangle(float l,float w){ lenght=l;widht=w;}
float GetArea();
float GetPerim();
};
float Rectangle::GetArea()
{ return area=(lenght*widht);}
float Rectangle::GetPerim()
{ return perim=2*(lenght+widht);}
class Circle:public shape
{ private:
float radius,area,perim;
public:
Circle(float x){ radius=x;}
float GetArea(){return perim=3.14*2*radius;}
float GetPerim(){ return area=3.14*radius*radius;}
};
void main()
{ Rectangle a(20,40);
Circle b(3);
cout<<"矩形的面积是"<
这个对么????
??嘿嘿,有点诡异?~
怎么帮?