问题及代码
/*
*ALL rights reserved.
*文件名称: 初学对象2
*作者:李长鸿
*完成时间:2015.3.18
*问题描述:长方体柱类的体积及表面积
*/
#include <iostream>
using namespace std;
class Bullk
{
private:
double length,width,heigth;
double volume,areas;
public:
void Setbullk();
void Volume();
void Areas();
};
void Bullk::Setbullk()
{
cin>>length>>width>>heigth;
}
void Bullk::Volume()
{
cout<<length*width*heigth<<" ";
}
void Bullk::Areas()
{
cout<<2*(width*length+length*heigth+width*heigth)<<" ";
}
int main()
{
Bullk bullk1,bullk2,bullk3;
bullk1.Setbullk();
bullk1.Volume();
bullk1.Areas();
cout<<endl;
bullk2.Setbullk();
bullk2.Volume();
bullk2.Areas();
cout<<endl;
bullk3.Setbullk();
bullk3.Volume();
bullk3.Areas();
return 0;
}
总结:在输出两个结果时,我想用空格,结果用单引号括起来的,就成了
这个模样了。。。开始百思不得其解,乱改,怀疑是输入函数不对,不能直接输入私有成员,又另外设了三个形参,挨个输入后赋值。。。
好吧,我原谅我啦