另一個c++練習的疑問

看板Programming作者時間17年前 (2008/03/01 15:32), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
我在 double volume(const double length, const double breadth, const double height) throw (...) 出現 12 C:\Documents and Settings\rong\桌面\新文件2.cpp expected identifier before '...' token 錯誤訊息呢? 附上我的語法..因不知該怎麼修改這個錯誤,只得丟上網路詢問,請大家協助了,謝謝 ! #include <iostream> using namespace std; class cbox { private: double m_length1; double m_breadth1; double m_height1; public : double volume(const double length, const double breadth, const double height) throw (...) { if (length < 0) { throw std::out_of_range(_T("length out of range")); } else if (breadth < 0) { throw std::out_of_range(_T("breadth out of range")); } else if (height < 0) { throw std::out_of_range(_T("height out of range")); } else { m_length1 = length; m_breadth1 = breadth; m_height1 = height; return m_height1 * m_length1 * m_breadth1; } } }; int main() { cbox box1; cbox box2; try { cout << "第一個箱子體積=" << box1.volume(10,50,60) << endl; } catch (std::exception& e) { std::cerr << "Caught: " << e.what() << endl; } try { cout << "第二個箱子體積=" << box2.volume(10,-10,20) << endl; //雖然資料有錯 但是東西仍產生了 只是這是不良品 } catch (std::exception& e) { std::cerr << "Caught: " << e.what() << endl; } cout <<endl; return 0; } -- ┌─────KKCITY─────┐  線上音樂新震撼   bbs.kkcity.com.tw ^_^ / 隨選隨播免等待 KKBOX ^_^ / └──From:140.109.123.38 ──┘   http://www.kkbox.com.tw   --
文章代碼(AID): #17oGPr00 (Programming)
文章代碼(AID): #17oGPr00 (Programming)