您的位置:首页 > 其它

第五周项目4:长方柱类

2016-03-26 20:10 204 查看
问题及代码:

#include <iostream>
using namespace std;

class bulk
{
public:
void set(double x,double y,double z);
void set();
void volume();
void areas();
private:
double length,width,heigth;
double vo,ar;
};
void bulk::set()
{
cout<<"请输入长、宽、高:";
cin>>length>>width>>heigth;
}
void bulk::volume()
{
vo=length*width*heigth;
cout<<"长方体的体积为:"<<vo<<endl;
}
void bulk::areas()
{
ar=(length*width+length*heigth+width*heigth)*2;
cout<<"长方体的表面积为:"<<ar<<endl;
}
int main()
{
bulk bu1;
bulk bu2;
bulk bu3;
bu1.set();
bu1.volume();
bu1.areas();
bu2.set();
bu2.volume();
bu2.areas();
bu3.set();
bu3.volume();
bu3.areas();
return 0;
}


运行结果:



知识点总结:

对类和对象的掌握。

学习心得:、

只要多加练习,就能够掌握这类知识。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: