作者karate362 (最近腰不痛的卡拉特)
看板EE_DSnP
标题[问题] HW5 compile error
时间Wed Dec 20 10:38:35 2006
或许是我没有搞清楚iterator的用法?
我在size()里这样写
iterator ni = begin();
按理说 begin()是传回一个iterator
我也有多载化 = 的运算子
但他却跟我说:
error: passing 'const SList<LTestObj>' as 'this' argument of
'SList<T>::iterator SList<T>::begin()' discards qualifers
请问这是怎麽回事呢?
另外 SList是使用了template的类别
那麽在它自己的member function 宣告一个iterator的时候
不用写SList<T>::iterator 写iterator就可以吗?
宣告一个SListnode时 语法一定要写成SListnode<int> node 这样的形式吗?
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 220.137.66.189
1F:推 ric2k1:size() is a const method. Unless you want to implement 12/20 20:22
2F:推 ric2k1:class const_iterator, please try to find some other way 12/20 20:22