第三单元作业 3.23
2015-04-01 18:42
330 查看
#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; }