#include <iostream>
using namespace std;
class Bulk
{
public:
double volume();
double areas();
void input();
void output(Bulk &s);
private:
double length;
double width;
double heigth;
};
double Bulk::volume()
{
return length*width*heigth;
}
double Bulk::areas()
{
double s=(length*width+length*heigth+width*heigth)*2;
return s;
}
void Bulk::input()
{
cout<<"请输入长:";
cin>>length;
cout<<"请输入宽:";
cin>>width;
cout<<"请输入高:";
cin>>heigth;
}
void Bulk::output(Bulk &s)
{
cout<<"长方柱的体积:"<<s.volume()<<endl;
cout<<"长方柱的表面积:"<<s.areas()<<endl;
}
int main()
{
Bulk c;
c.input();
c.output(c);
return 0;
}
运行结果:
长方柱类
最新推荐文章于 2014-06-14 16:37:51 发布