#include<iostream>
using namespace std;
class Cylinder
{
public:
Cylinder(double r,double h);
void vol()
{
cout<<"圆柱体的体积:"<<v<<endl;
}
void get()
{
v=3.14*radius*radius*high;
}
private:
double radius;
double high;
double v;
};
Cylinder::Cylinder(double r,double h)
{
radius=r;
high=h;
}
int main()
{
Cylinder cyl1(6.0,5.0);
cyl1.get();
cyl1.vol();
return 0;
}
第三单元作业 3.23
最新推荐文章于 2020-03-13 13:56:55 发布