关于STL Map的问题
multimap<int,string>mic;mic.insert(make_pair(3,"cap"));mic.insert(make_pair(0,"this")...
multimap<int,string> mic;
mic.insert(make_pair(3,"cap"));
mic.insert(make_pair(0,"this"));
mic.insert(make_pair(2,"a"));
mic.insert(make_pair(1,"is"));
multimap<int,string>::iterator pos_mumap;
for (pos_mumap=mic.begin();pos_mumap!=mic.end();++pos_mumap)
{
cout<< (*pos_mumap).second;
}
请问,这段代码错哪里了? 展开
mic.insert(make_pair(3,"cap"));
mic.insert(make_pair(0,"this"));
mic.insert(make_pair(2,"a"));
mic.insert(make_pair(1,"is"));
multimap<int,string>::iterator pos_mumap;
for (pos_mumap=mic.begin();pos_mumap!=mic.end();++pos_mumap)
{
cout<< (*pos_mumap).second;
}
请问,这段代码错哪里了? 展开
1个回答
展开全部
#include <map>
#include <iostream>
using namespace std;
int main()
{
multimap<int,string> mic;
mic.insert(make_pair(3,"cap"));
mic.insert(make_pair(0,"this"));
mic.insert(make_pair(2,"a"));
mic.insert(make_pair(1,"is"));
multimap<int,string>::iterator pos_mumap;
for (pos_mumap=mic.begin();pos_mumap!=mic.end();++pos_mumap)
{
cout<< (*pos_mumap).second<<" ";
}
return 0;
}
this is a cap
Process returned 0 (0x0) execution time : 0.031 s
Press any key to continue.
代码无明显语法逻辑问题,在gcc4.7下可以运行。
疑似环境其他因素。比如编译器、ide、路径设定等等
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询