【发布时间】:2016-07-29 17:33:35
【问题描述】:
我确实定义了以下结构
struct WayStruct{
double ID;
string Neighbours;
};
及以下地图
map <double,WayStruct> WayMap;
为了向这张地图添加一个新元素,我使用了
WaysFind.ID=999;
WaysFind.Neighbours="test";
WayMap.insert(1234,WaysFind);
但是我无法编译它。 Dev-C++ 以错误结束
[Error] no matching function for call to 'std::map<double, WayStruct>::insert(double, WayStruct&)'
谁能告诉我这里做错了什么?
当我使用 make_pair Dev-C++ 返回时
In instantiation of 'std::pair<_T1, _T2>::pair(const std::pair<_U1, _U2>&) [with _U1 = double; _U2 = int; _T1 = const char; _T2 = WayStruct]':
required from here
111 39 c:\program files (x86)\dev-cpp\mingw64\lib\gcc\x86_64-w64-mingw32\4.7.1\include\c++\bits\stl_pair.h [Error] no matching function for call to 'WayStruct::WayStruct(const int&)'
在文件 stl_pair.h 中
【问题讨论】:
-
你试过阅读文档吗?
-
嗨 Slava,是的,我有。我已经在网上扫描了一段时间了
-
没有
std::map的insert(key, value)方法,所以我是编译器,我可能也会抱怨。 -
@HB1963 在该链接的哪个位置显示
(key, value)? -
@HB1963 是的,我确定。首先,我知道
insert对于std::map的所有重载。其次,如果有这样的超载,你现在不会在这里。
标签: c++ c++11 dictionary