c++ - 没有运算符 "<<"匹配

标签 c++ dictionary c++03

#include<iostream>
#include<set>
#include<unordered_map>

using namespace std;

typedef long Node;

typedef unordered_map<Node, set<Node> > Dothi;

Dothi g;

while (n--)
{
    Node u, i;
    int choose;
    cin >> choose;
    if (choose == 1)
    {
        cin >> u >> i;
        cout << (Lienke(u, i) ? "TRUE" : "FALSE");
    }

    checkCase2 = false;

    if (choose == 2)
    {
        cin >> u;
        for (  auto n = g[u].begin(); n!=g[u].end();++n)
        {
            cout << n <<" "; //Error here, cant cout n
            checkCase2 = true;
        }
  • 我无法计算出以下行:“for( auto n = g[u].begin(); n!=g[u].end();++n )”。

  • 它说:“没有运算符”<<“匹配这些操作数”。

  • 我可以使用 c++2003

最佳答案

如果您想要在给定迭代器下打印一个值,那么您必须在其上使用解引用运算符:

cout << *n <<" ";
        ^ ~~~~ !

关于c++ - 没有运算符 "<<"匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42504847/

相关文章:

python - 如何用Python实现字典列表的多级排序?

c++ - 基类可以声明一个虚方法但不定义它吗?仍然在派生类中定义

c++ - boost中的path::string()和path::generic_string()有什么区别?

c++ - 错误 : unable to handle compilation, 预期在 '' 中恰好有一项编译器作业 [clang-diagnostic-error]

python - 使用 python 2.7 中的列表推导式将对象值列表连接到字符串中

java - Dozer 将 java.lang.Date(作为 Map 字段)映射到 XMLGregorianCalendar

c++ - STL find_if 和不区分大小写的字符串比较

c++将类方法作为参数传递给带有模板的类方法

c++ - LookAt(glm)返回错误的转换z值

c++ - 如何更改cmake中创建的文件的路径?