const_iterator(Node* curr, DList* theList)
接受一个非
const
DList *
,但它被称为
this
方法中的const
是const
,因此此处this
是const DList *
,不能用作期望非const
DList *
的参数的参数。简单的解决方法是替换
const_iterator(Node* curr, DList* theList)
{
curr_ = curr;
myList_ = theList;
}
与
const_iterator(Node* curr, const DList* theList):
curr_(curr),
myList_ (theList) // using member initializer list for reasons of taste
{
}
并且如果可能,请始终遵循const
正确性。例如,成员
DList* myList_;
必须成为
const DList* myList_;
或您刚刚移动了错误消息。问题中当前尚未完全实现的其他成员函数可能需要修改。
在我看来,这应该是可能的。