6_54.cpp
来自「C++程序设计技能百练随书配套光盘的源码」· C++ 代码 · 共 52 行
CPP
52 行
#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();
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?