我有以下结构定义问题地图
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开发-C++文件stl_pair.h返回与
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&)'
您是否尝试阅读文档? – Slava
嗨,斯拉瓦,是的,我有。我一直在扫描网络退出一段时间 – HB1963
“std :: map”没有'insert(key,value)'方法,所以我也可能抱怨编译器。 – WhozCraig