//编程建立类Cy,类Cy的构造两数被传递了两个double值,分别表示圆柱体的半径和高度。用类Cy计算圆柱体的体积,并存储在一个double变量中。在类Cy中包含一
个成员函数vo1(),用来显示#include<iostream>
using namespace std;
const double pa = 3.14;
class Cy
{
public:
Cy(double x = 0, double y = 0)
{
hight = x;
radius = y;
}
~Cy()
{
}
void num();
private:
double hight, radius;
};
void Cy::num()
{
double volum = 0;
volum = pa * radius * radius * hight;
cout << volum << endl;
}
int main()
{
Cy str(7.0,5.0);
str.num();
return 0;
}每个Cy对象的体积
03-09
551
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
05-29
3037
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)