#include<iostream>
using namespace std;
class Bulk
{
protected:
float lengh;
float height;
float width;
float area;
float volume;
public:
void get_value();
void display();
void get_volume();
void get_area();
};
void Bulk::get_value()
{cout<<"请输入长方体的数据"<<endl;
cin>>lengh;
cin>>height;
cin>>width;
}
void Bulk::get_volume()
{
volume=lengh*height*width;
}
void Bulk::get_area()
{area=2*(lengh*height+lengh*width+height*width);
}
void Bulk::display()
{
cout<<"这个长方体的面积为:"<<endl;
cout<<area<<endl;
cout<<"这个长方体的体积为:"<<endl;
cout<<volume<<endl;
}
int main()
{
Bulk t1,t2,t3;
t1.get_value();
t1.get_volume();
t1.get_area();
t1.display();
t2.get_value();
t2.get_volume();
t2.get_area();
t2.display();
t3.get_value();
t3.get_volume();
t3.get_area();
t3.display();
system("pause");
return 0;}
using namespace std;
class Bulk
{
protected:
float lengh;
float height;
float width;
float area;
float volume;
public:
void get_value();
void display();
void get_volume();
void get_area();
};
void Bulk::get_value()
{cout<<"请输入长方体的数据"<<endl;
cin>>lengh;
cin>>height;
cin>>width;
}
void Bulk::get_volume()
{
volume=lengh*height*width;
}
void Bulk::get_area()
{area=2*(lengh*height+lengh*width+height*width);
}
void Bulk::display()
{
cout<<"这个长方体的面积为:"<<endl;
cout<<area<<endl;
cout<<"这个长方体的体积为:"<<endl;
cout<<volume<<endl;
}
int main()
{
Bulk t1,t2,t3;
t1.get_value();
t1.get_volume();
t1.get_area();
t1.display();
t2.get_value();
t2.get_volume();
t2.get_area();
t2.display();
t3.get_value();
t3.get_volume();
t3.get_area();
t3.display();
system("pause");
return 0;}