#include <iostream>
using namespace std;
class Bulk
{
public:
void get_value();
void display();
private:
double lengh;
double height;
double width;
};
void Bulk::get_value()
{
cout<<"请输入长,宽,高:";
cin>>lengh>>width>>height;
}
void Bulk::display()
{
cout<<"表面积是:"<<2*(lengh*width+lengh*height+height*width)<<endl;
cout<<"体积是:"<<lengh*width*height<<endl;
}
int main()
{
Bulk b1,b2,b3;
b1.get_value();
b1.display();
b2.get_value();
b2.display();
b3.get_value();
b3.display();
return 0;
}
长方体类
