#include<iostream>
using namespace std;
class Bulk
{
public:
Bulk(double x=1.0,double y=1.0,double z=1.0):length(x),width(y),height(z) {};
void get_value();
double area();
double valum();
void output();
private:
double length;
double width;
double height;
};
double Bulk::area()
{
double s;
s=length+width+height;
return s;
}
double Bulk::valum()
{
double v;
v=length*width*height;
return v;
}
void Bulk::get_value()
{
cin>>length>>width>>height;
}
void Bulk::output()
{
cout<<"面积:"<<area()<<endl;
cout<<"体积:"<<valum()<<endl;
}
int main()
{
int i=0;
Bulk b[5]={Bulk(2.3,4.5,6.7),Bulk(1.5,3.4),Bulk(10.5)};
b[4].get_value();
for(i=0; i<5; i++)
{
b[i].area();
b[i].valum();
b[i].output();
}
return 0;
}
07-18
07-18
07-18
07-18
07-18
07-18
07-18
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交