#include <iostream>
using namespace std;
class Bulk
{
public:
void set();
void c_volume();
void c_areas();
private:
double length;
double width;
double heigth;
};
void Bulk::set()
{
double l,w,h;
cout<<"请分别输入长、宽、高:";
cin>>l>>w>>h;
length=l;
width=w;
heigth=h;
}
void Bulk::c_volume()
{
double v;
v=length*width*heigth;
cout<<"体积为:"<<v<<endl;
}
void Bulk::c_areas()
{
double a;
a=(length*width+length*heigth+width*heigth)*2;
cout<<"表面积为:"<<a<<endl;
}
int main()
{
Bulk x,y,z;
x.set();
y.set();
z.set();
x.c_volume();
x.c_areas();
y.c_volume();
y.c_areas();
z.c_volume();
z.c_areas();
return 0;
}
运行结果: