利用虚函数实现的多态性来求四种几何图形的面积.这四种几何图形是:三角形、矩形、正方形和圆.几何图形

问题描述:

利用虚函数实现的多态性来求四种几何图形的面积.这四种几何图形是:三角形、矩形、正方形和圆.几何图形

class Cric{
public:
Cric(){};
Cric(int x,int y,int c){
cx=x;cy=y;bj=c;
};
Cric(){};
private:
int cx,cy;
int bj;
public:
void ShowM(){
cout<<"面积"<< 2*3.1415926*bj*bj<<endl;
};
};
class CricEx:public Cric{
public:
CricEx(){};
CricEx(){};
private:
int height;
public:
void ShowV(){
cout<<"体积:"<< 2*3.1415926*bj*bj*height<<endl;
};
};
.
请参考