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

关于map的键值类型的有关问题

2012-03-07 
关于map的键值类型的问题代码很简单,大致如下#includeiostreamusingnamespacestd#includestring#incl

关于map的键值类型的问题
代码很简单,大致如下

#include   <iostream>
using   namespace   std;
#include   <string>
#include   <map>

typedef   struct
{
string   a;
string   b;
char   c;
}Item;

typedef   map <Item,   int>   FM;

void   main()
{
FM   fm;
Item   fi;
fi.a= "aaaaaa ";
fi.b= "mmmmmmmm ";
fi.c= 'c ';
if(!fm.count(fi))
                        cout < < "There   is   no   the   key   in   the   map " < <endl;
}

其中,fm.count()一句链接时有7个很奇怪的错误,都指向同一个地方,大家可以自己编译看看,这里不便描述。为什么会这样呢?关键是有什么方法可以解决该问题呢?
还请高手指教啊!

[解决办法]
需要为 Item 定义若干操作
[解决办法]
Item类型没有 <运算符。
[解决办法]
The object must have a default constructor,
an accessible destructor, and
an accessible assignment operator. //缺少这个

热点排行