作者Tverous (Orah~)
看板C_and_CPP
標題[問題] const pointer & pointer to const
時間Fri Sep 13 11:45:08 2019
各位先進打擾了
其實已大概了解兩者之間的差異
最主要是想請C++ primer 5e的部分內容
在書中介紹const pointer的定義是無法修改pointer的存的值
https://imgur.com/WVNrENJ
另外也提到const_iterator本身是一個const pointer?
https://imgur.com/tmwALqV
這部分就使我搞混
因為既然是const pointer的話 對其值的修改應該是不允許才對
但編譯器(x86_64-w64-mingw32)卻允許
https://imgur.com/JxdG2OC
在這請叫各位先進說是否有理解錯誤的地方
非常感謝
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 1.161.230.188 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1568346310.A.19D.html
※ 編輯: Tverous (1.161.230.188 臺灣), 09/13/2019 11:46:09
※ 編輯: Tverous (140.119.96.107 臺灣), 09/13/2019 11:48:06
※ 編輯: Tverous (140.119.96.107 臺灣), 09/13/2019 11:49:56
→ loveme00835: 書裡用錯字了 09/13 12:00
→ stucode: const_iterator 語意上是 pointer to const 09/13 12:04
→ Tverous: 了解 那看來應該的確是書裡用錯字 非常感謝各位! 09/13 12:07