问题就在标题中,我以前用过它,但现在不起作用:
for (list<string>::iterator it = list1.begin(); it != list1.end(); it++){
cout << *it;
}
错误如下:
“没有运算符”<<”与这些操作数匹配 操作数类型为: std::ostream << std::string "
我已经有 2 年没有使用过 C++ 了,现在我被困在这里,使用了 google 但没有找到任何好的答案。
预先感谢您的回答!
最佳答案
您忘记包含 header ,很可能 <string>
(或者,更不可能的是 <iostream>
或 <list>
)。所有这三个都是必需的,您不能依赖任何标准库 header ,包括另一个。
关于c++ - 如何使用迭代器计算列表的值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35009675/