#include<iostream>
using namespace std;
const double PI=3.14;
class cylinder{
double r;
double h;
public:cylinder ()
{r=0;
h=0;
}
cylinder(double x,double y)
{r=x;
h=y;
}
double vol()
{return PI*r*r*h;
}
void display();
private:
double redius,high;
};
void cylinder::display()
{cout<<"The redius is:"<<r<<","<<"the high is:"<<h<<endl;
cout<<"the volume is:"<<vol()<<endl;
}
int main()
{cylinder c1(3,6),c2;
cout<<"The volume of c1 is:"<<endl;
c1.display();
cout<<"The volume of c2 is:"<<endl;
c2.display();
return 0;
}
3.23
最新推荐文章于 2022-05-13 16:11:59 发布