/*
* 程序的版权和版本声明部分
* Copyright (c)2012, 烟台大学计算机学院学生
* All rightsreserved.
* 作者: 李洋
* 完成日期: 2013年 3 月 31 日
* 版本号: v1.0
* 输入描述:无
* 问题描述:无
* 程序输出:无
*/
#include <iostream>
using namespace std;
class Bulk
{private:
double length;
double width;
double heigth;
public:
Bulk();
Bulk(double l=1.0,double w=1.0,double h=1.0);
void get_value();
void volume();
void areas();
};
Bulk::Bulk()
{
length=1.0;
width=1.0;
heigth=1.0;
}
Bulk::Bulk(double l,double w,double h)
{
length=l;
width=w;
heigth=h;
}
void Bulk::get_value()
{
double l,w,h;
cout<<"请输入长方柱的长、宽、高: "<<endl;
cin>>l>>w>>h;
length=l;
width=w;
heigth=h;
}
void Bulk::volume()
{
cout<<"该长方柱的体积为:"<<length*width*heigth<<endl<<endl;
}
void Bulk::areas()
{
cout<<"该长方柱的表面积为:"<<(length*width+width*heigth+length*heigth)*2<<endl<<endl;
}
void main()
{
Bulk b[5]={Bulk(2.3,4.5,6.7),Bulk(1.5,3.4),Bulk(10.5)};
b[0].volume();
b[0].areas();
b[1].volume();
b[1].areas();
b[2].volume();
b[2].areas();
b[3].volume();
b[3].areas();
b[4].get_value();
b[4].volume();
b[4].areas();
}