error C2784--------使用map遇到的小问题
2014-06-10 01:50
183 查看
1、关于functional(86): error C2784
在使用map时,当键或值有string时,需要#include,千万不要写成#include "string.h"。否则会出现xxxxxinclude\functional(86) : error C2784: 'bool __cdecl std::operator <(const class std::multimap<_K,Ty,_Pr,_A> &,const class std:: multimap<_K,_Ty,_Pr,_A> &)': could not deduce
template argument for ' const class std::multimap<_K,_Ty,_Pr,_A> &' from 'const class std::basic_string,class std::allocator>'
.......
这样之类的错误
map中的key是默认以less<>序升序排列的,也就是说key本身要支持operator<,所以需要添加string头文件,大抵是因为里面包含了string类的各种操作。
2、关于#Include "String"和#Include "String.h"
C的标准库里已经有一个名字叫做“string.h”的头文件,包含一些常用的C字符串处理函数。C++里则多了string这个头文件,里边有>和<等等操作,两者有不同的内容。
3、关于减少警告提示
在#include 之前加上#pragmawarning(disable:4786)可以减少使用map时产生的一些警告。
相关文章推荐
- (原创)android中使用Baidu Map遇到的问题之:移动Mapview上的放大缩小控件
- 使用Google Map API可能会遇到的问题汇总
- 使用map遇到的两个问题及解决办法
- android中使用Baidu Map遇到的问题之:移动Mapview上的放大缩小控件
- c++中使用std::map是遇到的小问题
- java Map使用遇到的问题
- Kotlin中使用RxJAVA的map()操作符遇到的问题
- 在win2003server上使用移动硬盘时遇到的问题以及禁用“关闭事件跟踪程序”
- 在nhibernate使用过程中遇到的几个问题。
- 在nhibernate使用过程中遇到的几个问题02
- 关于您提到使用WebServices时候遇到“基础连接以关闭”的问题
- 求解在SQL中使用了where列所遇到的问题
- 使用Data Access Application Block遇到的问题
- 遇到 Web Server 中不能使用 XmlSerializer 的问题
- updater application block v2.0的使用过程中遇到的问题及解决办法
- 使用css expression遇到的一个问题
- 使用Access存储Session,遇到了SessionId问题?
- 在使用BizTalk时遇到一个很郁闷的问题 之解决篇
- 在IIS 6 中使用HTTP压缩(Compression)遇到的一个问题
- 使用vs.net遇到的问题