[問題] 自定義度串列Iterator

看板C_and_CPP作者時間8年前 (2017/12/07 23:16), 8年前編輯推噓0(004)
留言4則, 2人參與, 8年前最新討論串1/1
開發平台(Platform): (Ex: Win10, Linux, ...) 編譯器(Ex: GCC, clang, VC++...)+目標環境(跟開發平台不同的話需列出) gcc 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) 問題(Question): 自定義的iterator用在複製建構子的時候無法正確運作 餵入的資料(Input): 預期的正確結果(Expected Output): 錯誤結果(Wrong Output): 程式碼(Code):(請善用置底文網頁, 記得排版) https://repl.it/repls/AcrobaticUnwelcomeAegeancat 照著Horowitz的資結C++實作這個Iterator類別,194行可以正常使用但是在複製建構子卻不? -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 125.224.130.3 ※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1512659791.A.16A.html ※ 編輯: nova06091 (125.224.130.3), 12/07/2017 23:17:09

12/07 23:30, 8年前 , 1F
begin() 沒有 const 修飾不能在有 const 的 a 上面呼叫。
12/07 23:30, 1F

12/07 23:31, 8年前 , 2F
194 行的 list 是 non-const 的。
12/07 23:31, 2F

12/08 10:46, 8年前 , 3F
建議 編譯的時候把warning全開喔 有些"顯而易見"的問題
12/08 10:46, 3F

12/08 10:46, 8年前 , 4F
編譯器都有幫你發現
12/08 10:46, 4F
※ 編輯: nova06091 (49.214.32.56), 12/08/2017 10:58:51 可以了 謝謝你們 > < ※ 編輯: nova06091 (49.214.32.25), 12/11/2017 13:31:45
文章代碼(AID): #1QALjF5g (C_and_CPP)