我有以下結構定義問題地圖
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