error C2664-----STL学习
来源:互联网 发布:卫生网络试题及答案 编辑:程序博客网 时间:2024/06/04 19:38
错误位:“错误1error C2664: 'std::map<_Kty,_Ty>::map(const std::less<_Ty> &)' : cannot convert parameter 1 from 'const std::pair<_Ty1,_Ty2>' to 'const std::less<_Ty> &'”;
错误代码:
map<int,map<int,int>> coll;
coll.insert(make_pair(7,make_pair(1,1)));
错误原因:
make_pair()函数的返回值的类型为pair<int,int>。因此,make_pair(7,make_pair(1,1))的返回值的结果为pair<int ,pair<int ,int>>;
但是我们先前定义的map内的类型为<int ,map<int,int>>,因此<int ,pair<int ,int>不符合定义,不能进行操作!而且在pair和map之间没有类型转化,因此也不能强制类型转化。
修改措施:
方法一:
map<int,map<int,int>> coll;
map<int,int> temp;
temp.insert(make_pair(1,1));
coll.insert(make_pair(7,temp));
方法二:
map<int,pair<int,int>> coll;
coll.insert(make_pair(7,make_pair(1,1)));
方法三:
map<int,map<int,int>> coll;
coll.insert(make_pair(7,map<int,int>().insert(1,1)));
- error C2664-----STL学习
- error C2664-----STL学习
- error C2664
- error C2664
- ERROR C2664
- error C2664:
- error C2664
- error C2664
- error C2664,error C2039
- VC2005 error C2664
- error C2664 c++
- error C2664: “MessageBoxW”解决方案
- error C2664的解决方法
- 关于error C2664
- error C2664: 'LoadImageW'
- Error C2664 解决方法
- VS2008 出现 error C2664
- error C2664: “MessageBoxW”解决方案
- STM32 调试时,出现:cannot access memory!!!
- jQuery动态添加、删除表格行
- 如何证明NP-Complete问题(how to handle np-complete problem)
- 老电子工程师的多年经验电子产品设计经验总结之PCB设计
- new和malloc的区别
- error C2664-----STL学习
- error C2664-----STL学习
- 一个最简单的例子,清楚说明回调函数的作用和强大功能
- List Control 显示中文(中文非乱码)
- wcf 4.0 中Rest service 在iis host中不用.svc文件的配置
- 学习 webservices
- 程序员的可爱与执着_2
- Android 反编译工具汇总
- JSON定义一维和二维数组格式