看板Programming
标 题请教c++的物件
发信站KKCITY (Tue May 1 07:00:50 2007)
转信站ptt!ctu-reader!ctu-gate!news.nctu!news.ntu!news.au!zoonews.ee.ntu!news
当我输入了箱子的长宽高之後
回应的体积为0
请问我在物件的操作上
是否遗漏了什麽呢
附上原始程式,麻烦各位点醒我哪里出错
谢谢!
class CBox
{
private:
double m_Length;
double m_Breadth;
double m_Height;
public:
double Volume1(double a)
{
m_Length=a;
return m_Length;
}
double Volume2(double b)
{
m_Breadth=b;
return m_Breadth;
}
double Volume3(double c)
{
m_Height=c;
return m_Height;
}
double Volume()
{
return m_Length*m_Breadth*m_Height;
}
};
#include <iostream>
using namespace std;
int main()
{
CBox box1;
double a1,b1,c1;
cout << endl
<< "box1 长度= " << endl;
cin >> a1;
box1.Volume1(a1);
cout << endl
<< "box1 宽度= " << endl;
cin >> b1;
box1.Volume1(b1);
cout << endl
<< "box1 高度= " << endl;
cin >> c1;
box1.Volume1(c1);
cout << endl
<< "Volume of box1 = "
<< box1.Volume();
cout << endl;
system("PAUSE");
return 0;
}
--
┌─────◆KKCITY◆─────┐ ◢╱ 只要你
通过身份认证 ~ ◥█
│ bbs.kkcity.com.tw │ █▉─ 免经验、五人连署即开班系板 ◥
└──《From:218.169.108.128
》──┘ ◥╲ 赶快为班上设个
秘密基地吧!
◢
--