#include <iostream>
using namespace std;
class cylinder{
private:
double radius, height, volume;
public:
cylinder(int rad, int hei);//构造函数原型说明
double getVol();
void vol();
};
cylinder::cylinder(int rad, int hei)//定义构造函数
{
radius = rad;
height = hei;
}
double cylinder::getVol()
{
volume = 3.14 * radius * radius *height;
return volume;
}
void cylinder::vol()
{
cout << "圆柱体的体积是: " << volume <<endl;
}
第三章作业3.23
最新推荐文章于 2022-07-14 22:26:07 发布