6_54.cpp
上传用户:zipjojo
上传日期:2009-07-20
资源大小:70k
文件大小:1k
- #include<iostream.h>
- const double pi=3.1415926;
- class Column
- {
- public:
- void SetColumn();
- double getvolume();
- double getsurface();
- void disp();
- private:
- double radius;
- double height;
- };
- void Column::SetColumn()
- {
- double r,h;
- cout<<"Input the radius and height of a column!";
- cout<<endl;
- cout<<"radius=";
- cin>>r;
- cout<<"height=";
- cin>>h;
- radius=r;
- height=h;
- }
- inline double Column::getvolume()
- {
- return pi*radius*radius*height;
- }
- inline double Column::getsurface()
- {
- return 2*pi*radius*(height+radius);
- }
- void Column::disp()
- {
- cout<<"The volume of the column is "<<Column::getvolume();
- cout<<endl;
- cout<<"The surface of the column is "<<Column::getsurface();
- cout<<endl;
- }
- void main()
- {
- Column mycolumn;
- mycolumn.SetColumn();
- mycolumn.getvolume();
- mycolumn.getsurface();
- mycolumn.disp();
- }