求c++问题的解答。。。。。。。。。

来源:百度知道 编辑:UC知道 时间:2024/06/04 13:03:09
类Block用来描述长方体,数据成员length、width、height记录长方体的长、宽和高。成员函数volume()求长方体的体积,surface()求长方体的表面积,并用main()函数来描述。

请问哪位大侠能够回答啊?谢谢!

嘿,小弟,看在我们都是浙江射手座帅气的中国男人份上,能给我就给我好了,哈!不给也要来关问题,最近编程序都没人关问题,哎,世道不济,老子老是白忙活,你可别伤了偶们的心……

#include<iostream.h>
class Block
{
private:
float length;
float weigth;
float height;
float v;
float s;
public:
Block(float l,float w,float h)
{
length=l; weigth=w; height=h;
}
void volume()
{
v=length*weigth*height;
}
void surface()
{
s=2*(length*weigth+weigth*height+height*length);
}
void disp()
{
cout<<"体积为:"<<v<<",表面积为:"<<s<<endl;
}
};
void main()
{
float l,w,h;
cout<<"输入立方体的长,宽,高:";
cin>>l>>w>>h;
Block b(l,w,h);
b.volume();
b.surface();
b.disp();
}

#include<iostream.h>
class Block
{
private:
float length;
float weigth;
float heig