Is it impossible to use an STL map together with a struct as key?

前端 未结 6 2204
离开以前
离开以前 2020-12-14 03:46

I have the following code:

struct Node
{
  int a;
  int b;
};

Node node;
node.a = 2;
node.b = 3;

map aa;
aa[1]=1; // OK.

map

        
6条回答
  •  甜味超标
    2020-12-14 04:06

    Could you please post the compiler error - They're intended to tell you, what's wrong.

    I guess your error occurs since Node doesn't implement a comparison operator which is required by the map in order to identify it's elements.

提交回复
热议问题