[問題] C++Primer,4ed中文版,p598頁...

看板C_and_CPP (C/C++)作者 (....)時間12年前 (2013/08/07 15:14), 編輯推噓0(003)
留言3則, 2人參與, 最新討論串1/1
開發平台(Platform): (Ex: VC++, GCC, Linux, ...) VC 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) 問題(Question): 這本課本的範例跑不起來.. http://codepad.org/FmgA9HrQ 餵入的資料(Input): 預期的正確結果(Expected Output): 課本的預期結果,上面兩個有編譯錯誤的地方,應該是執行期才決定的,但是卻變成 編譯錯誤 錯誤結果(Wrong Output): 錯誤 1 error C2662: 'Item_base::net_price' : 無法將 'this' 指標從 'const Item_base' 轉換成 'Item_base &' g:\cpp\hello\hello\hello.cpp 28 hello 錯誤 2 error C2662: 'Item_base::net_price' : 無法將 'this' 指標從 'const Item_base' 轉換成 'Item_base &' g:\cpp\hello\hello\hello.cpp 29 hello 程式碼(Code):(請善用置底文網頁, 記得排版) http://codepad.org/FmgA9HrQ 補充說明(Supplement): -- -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.40.121.162

08/07 15:21, , 1F
你的net_price不是const member function
08/07 15:21, 1F

08/07 20:57, , 2F
你是說這樣嗎?http://codepad.org/IWFGmJh2
08/07 20:57, 2F

08/07 22:33, , 3F
我是說Bulk_item跟Item_base的
08/07 22:33, 3F
文章代碼(AID): #1I0VFfk3 (C_and_CPP)
文章代碼(AID): #1I0VFfk3 (C_and_CPP)