# include
# define PI 3.14159 class Rectangle//定义一个长方体类
{
protected:float Length,Width;
float Centerx,Centery;
public:
Rectangle(float l,float w,float x,float y)
}
Length=l;
Width=w;
Centerx=x;
Centery=y;
}
float Area(void)
{
return Length*Width;
}
};
class Circle//定义一个圆形类
{
protected:float radius;
float Centerx,Centery;
public:
Circle(float r,float x,float y)
{
radius=r; Centerx=x; Centery=y;
}
double Area(void)
{
return radius*radius*PI;
}
};
class Cuboid:public Rectangle,public Circle //由基类Rectangle、Circle派生出类
Cuboid
{
private:
float High;
double RVolume,CVolume;
public: Cuboid(float l,float w,float x1,float y1,float r,float x2,float y2,float h):Rectangle(l,w,x1,y1),Circle(r,x2,y2) { High=h;
}
void Vol(void) //分别计算长方体和圆柱体的体积
{
RVolume=Rectangle::Area()*High;
CVolume=Circle::Area()*High; } void Show(void)//分别显示长方体和圆柱体的信息
{
cout<<"Length="<
{
Cuboid cub(10,10,10,20,30,30,10,10);
cub.Show();
}
不给分,估计没人做的