作者wilson8069 (E T)
看板EE_DSnP
標題[問題] hash裡函式的const
時間Tue Jan 17 02:17:23 2012
想請問ric老師
我在寫myHash.h時,
裡面的兩個函式 iterator begin() const 和 iterator end() const
compile一直不過,
會有"invalid conversion"等錯誤訊息...
但是將const刪掉後,compile就過了,而且hash可以正常運作
想問說此兩函式const如果刪掉的話,作業交出去compile可以過嗎?
謝謝!!!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.25.106
1F:→ djshen:有傳this進去? 01/17 02:26
2F:→ wilson8069:嗯嗯 01/17 02:28
3F:→ djshen:const_cast<Hash*>(this) 01/17 02:33
4F:推 ric2k1:推樓上! 01/17 03:10
5F:→ wilson8069:真的太感謝了!!! 01/17 03:46
6F:推 kickpp:我猜是不是iterator的constructor parameter的type沒弄好? 01/17 03:47
7F:→ kickpp:哦 解決了阿= = 01/17 03:47
8F:推 james54333:阿... 我直接傳this會過 這樣沒問題嗎? 01/17 09:11