首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

stl map的第一个元素不能是一个自定义的结构体对把?该如何解决

2012-02-12 
stl map的第一个元素不能是一个自定义的结构体对把?#includemap#includeiostreamusingnamespacestdin

stl map的第一个元素不能是一个自定义的结构体对把?
#include   <map>
#include   <iostream>
using   namespace   std;

int   main()
{
typedef   struct   {string   cout;   string   name;}   key;
map <key,   int>   info;
key   key1;
key1.cout   =   "chinese ";
key1.name   =   "chendong ";
info.insert(make_pair(key1,   1));
return   0;
}


是不是不可以这样?

[解决办法]
自定义结构体要有:
bool operator <(const T& t) const
{
...
}

热点排行