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
{
...
}