在Cclipse IDE中,对于C/C++开发人员Posiy(4.8),我得到了一个错误的参数错误。
map_name.insert(make_pair("string_name", int_name);
.
我使用的是gcc8.2.0。我在用STL做一些简单的东西。
两个都试过了
insert(make_pair())
insert(pair<string, int>())
获取相同的IDE错误(语义错误)。为什么?
#include <iostream>
#include <map>
using namespace std;
int main()
{
map<string, int> ages;
ages["Mike"] = 21;
ages["Johnny"] = 20;
ages["Vicky"] = 30;
ages["Mike"] = 42;
// ages.insert(make_pair("Peter", 100));
ages.insert(pair < string, int > ("Peter", 100));
for(map<string, int>::iterator it = ages.begin(); it!=ages.end(); it++)
{
cout<< it->first<<": "<< it->second<<endl;
}
return (0);
}
这是IDE中显示的错误: