請教c++的物件
當我輸入了箱子的長寬高之後
回應的體積為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 》──┘ ◥╲ 趕快為班上設個秘密基地吧! ◢
--
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 2 篇):
Programming 近期熱門文章
PTT數位生活區 即時熱門文章