Unit5_problem3_形体芸術.
1495 ワード
/*Univercity:
*@Class</A> 134~4
*@Author:
*@Time:2014-3-18
*@Function:
*@Args:
*@Return:
*/
#include <iostream>
#include<Cmath>
using namespace std;
class Bulk
{
public:
Bulk(double l=1.0,double w=1.0,double h=1.0):length(l),width(w),heigth(h) {};
double volume();//
double area();//
void showMessage();
void get_value();
private:
double length,width,heigth;
};
double Bulk::volume()
{
return length*width*heigth;
}
double Bulk::area()
{
return (length*width+length*heigth+width*heigth)*2;
}
void Bulk::showMessage()
{
cout<<" :"<<length<<" :"<<width<<" :"<<heigth<<endl;
cout<<" :"<<volume()<<", :"<<area()<<endl<<endl;
}
void Bulk::get_value()
{
cout<<" :";
cin>>length>>width>>heigth;
}
int main()
{
Bulk b[5]= {Bulk(2.3,4.5,6.7),Bulk(1.5,3.4),Bulk(10.5)};
b[4].get_value();
// 5
for(int i=0; i<5; i++)
{
b[i].showMessage();
}
}
/* :
“;”
!!!*/