我有一个写入函数,我用它来将列表的内容写入文件。该列表仅包含数字。
list<int>::iterator pos;
for (pos = listStorage.begin(); pos != listStorage.end(); ++pos)
{
out << *pos << endl;
}
return out;
我在编译时遇到错误;
error C2679: binary '=' : no operator found which takes a right-hand operand of type 'std::list<_Ty>::_Const_iterator<_Secure_validation>' (or there is no acceptable conversion)
有人可以帮忙吗?谢谢
最佳答案
我相当确定这是一个常量问题。您的 listStorage 对象是否声明为 const?如果是这样,您需要将迭代器声明为
const list<int>::iterator pos;
关于c++ - 如何将链表的内容写入文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5858920/