您的位置:首页 > 其它

第三周实验报告 任务四

2012-03-11 17:17 288 查看
源代码:
#include<iostream>

using namespace std;

class Cub
{
public:

void get_side();

void display();

private:

float length;

float width;

float height;
};

void Cub::get_side()
{
cin>> length;

cin>> width;

cin>> height;
}

void Cub::display()
{
cout<< "运算数据为:" <<endl;

cout<< "volume = " << length * width * height << endl;

cout<< "areas = " << 4 * (length * width) + 2 * (width * length) << endl;
}

int main()
{
Cub c1, c2, c3;

cout<< "请输入第一个长方体的数据:";

c1.get_side();

c1.display();

cout<< "请输入第二个长方体的数据:";

c2.get_side();

c2.display();

cout<< "请输入第三个长方体的数据:";

c3.get_side();

c3.display();

return 0;
}


截图:



收获:自己定义了类,体验了这个过程···而不是再照着代码敲,收获不小··

感想:以后一定要积极发博文!!!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  任务 c float