./*
* 程序的版权和版本声明部分
* Copyright (c)2012, 烟台大学计算机学院学生
* All rightsreserved.
* 文件名称: fun.cpp
* 作 者:谷志恒
* 完成日期:2013 年3月19日
* 版本号: v1.0
* 对任务及求解方法的描述部分:类与长方体
* 输入描述:略
* 问题描述:略
* 程序输出:如下
*/
#include <iostream>
using namespace std;
class Bulk
{
public:
void get_value();
void display();
private:
void get_volume();
void get_areas();
float height;
float width;
float length;
float volume;
float areas;
};
void Bulk::get_value()
{
cout<<"分别输入长方柱的长,宽,高:";
cin>>length;
cin>>width;
cin>>height;
get_volume();
get_areas();
}
void Bulk::get_volume()
{
volume=height*width*length;
}
void Bulk::get_areas()
{
areas=height*width*2+height*length*2+width*length*2;
}
void Bulk::display()
{
cout<<"长方体的体积为:"<<volume<<endl;
cout<<"长方体的表面积为:"<<areas<<endl;
cout<<endl;
}
int main()
{
Bulk a,b,c;
a.get_value();
a.display();
b.get_value();
b.display();
c.get_value();
c.display();
return 0;
}
运行程序;
x心得体会:大体结构知道了,但是具体意思还是不大懂啊!!