gpt4 book ai didi

c++ - 错误 : no match for 'operator=' in 'iter = ((const FHlist*)theList)->FHlist::begin [with Object = Employee]()'
转载 作者:行者123 更新时间:2023-11-28 03:05:46 25 4
gpt4 key购买 nike

我在做一个散列函数,它不会编译,我复制了下面的函数。谢谢你的帮助,请原谅我的英语

template <class Object>
bool FHhashSC<Object>::contains(const Object & x) const
{
const FHlist<Object> &theList = mLists[myHash(x)];
typename FHlist<Object>::iterator iter;

for (iter = theList.begin(); iter != theList.end(); iter++)
if (*iter == x)
return true;

// not found
return false;
}

最佳答案

您应该使用 const_iterator,因为 theList 是一个常量对象。

关于c++ - 错误 : no match for 'operator=' in 'iter = ((const FHlist<Employee>*)theList)->FHlist<Object>::begin [with Object = Employee]()' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19776315/

25 4 0