#include<iostream>
using namespace std;
class container
{
public:
container(){};
container(doubleradius1)
{
a=radius1;
}
virtualvoid surface_area()=0;
virtualvoid volume()=0;
public:
doublea;
};
class cube:public container
{public:
cube(doubleradius1):container(radius1)
{;}
virtualvoid surface_area()
{
doublex;
x=a*a*6;
cout<<"正方体的面积:"<<x<<endl;
}
virtualvoid volume()
{
doubley;
y=a*a*a;
cout<<"正方体的体积:"<<y<<endl;
}
};
class sphere:public container
{public:
sphere(doubleradius1):container(radius1)
{;}
virtualvoid surface_area()
{
doublei;
i=4*3.14*a*a;
cout<<"球的表面积:"<<i<<endl;
}
virtualvoid volume()
{
doublej;
j=4/3*3.14*a*a*a;
cout<<"球的体积:"<<j<<endl;
}
};
class cylinder:public container
{public:
cylinder(doubleradius1,double high):container(radius1)
{
e=high;
}
virtualvoid surface_area()
{
doublep;
p=2*3.14*a*a+2*a*e;
cout<<"圆柱体的表面积:"<<p<<endl;
}
virtualvoid volume()
{
doubleq;
q=3.14*a*a*e;
cout<<"圆柱体的体积:"<<q<<endl;
}
private:
doublee;
};
int main()
{
cubemb(20),*ma;
spheremp(20),*mc;
cylindermq(20,10),*md;
ma=&mb;
ma->surface_area();
ma->volume();
mc=∓
mc->surface_area();
mc->volume();
md=&mq;
md->surface_area();
md->volume();
return0;
}