用继乘求圆柱的表面积和体积
#include<iostream>using namespace std;
class Circle
{
protected:
float R,S,C;
public:
Circle(float r,float s,float c)
{
R=r;
S=s;
C=c;
}
void display()
{
S= 3.14*R*R;
C=3.14*2.*R;
cout<<S<<endl;
cout<<C<<endl;
}
};
class Height
{
public:
float h;
void set_H()
{
cin>>h;
}
Height()
{
H=h;
}
protected:
float H;
};
class Cylinder:public Circle ,public Height
{
public:
Cylinder (float s3,float v,float s,float c,float h)//从这里有问题了
{
S3=s3;
V=v;
S=s;
C=c;
H=h;
}
void display()
{
S3=C+S;
V=S*H;
cout<<S3<<endl;
cout<<V<<endl;
}
protected:
float S3,V,S,C,H;
};
void main()
{
Circle ci(2.0);
ci.display();
Height he(4.0);
Cylinder cy;
cy.display();
}
在Height类和Circle类中多重派生出Cylinder类,在Cylinder 类中求出圆柱的表面积和体积.求大师帮忙!