標籤

C++ (12) Linux (6) MacOSX (4) Makefile (3) Matlab (3) Ubuntu (3) Android (2) C (1) Refactoring (1)

2011年9月29日 星期四

[C++] passing "const ..." as this argument discards qualifiers

小時候不懂事
每次code改過看到compile error就把code改回去
(因為error都看不懂 @@)
長大後才發現
原來只是我英文太差= =
compiler其實都寫得滿詳細的

為了解決看不懂compile error的問題
我決定把遇到的錯誤都給它記下來
這樣哪天忘了就不用再Google啦!



有時候會不小心雞猴
在函式的參數清單裡加上const
結果還用non const method
這時候compiler就會該說

error: passing "const ..." as this argument discards qualifiers


把const去掉或是改用const method就可以解決問題囉!
(也可以用const_cast)

沒有留言:

張貼留言