請教c++的物件

看板Programming作者時間18年前 (2007/05/01 07:32), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/2 (看更多)
當我輸入了箱子的長寬高之後 回應的體積為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 ──┘ ◥╲ 趕快為班上設個秘密基地吧! --
文章代碼(AID): #16Ddnp00 (Programming)
討論串 (同標題文章)
文章代碼(AID): #16Ddnp00 (Programming)