作者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