multimap 如何遍历
#include<string>#include<map>usingnamespacestd;voidmain(){typedefmultimap<string,stri...
#include <string>
#include <map>
using namespace std;
void main()
{
typedef multimap<string,string> M;
M author;
author.insert(make_pair("Tom","Good"));
author.insert(make_pair("Herry","Yeah"));
author.insert(make_pair("Tom","wefef"));
author.insert(make_pair("Herry","hehehaha"));
author.insert(make_pair("Herry","comcomcomcom"));
for (M::iterator iter = author.begin(); iter != author.end(); ++iter)
{
cout<<iter->first<<endl; //出错
}
} 展开
#include <map>
using namespace std;
void main()
{
typedef multimap<string,string> M;
M author;
author.insert(make_pair("Tom","Good"));
author.insert(make_pair("Herry","Yeah"));
author.insert(make_pair("Tom","wefef"));
author.insert(make_pair("Herry","hehehaha"));
author.insert(make_pair("Herry","comcomcomcom"));
for (M::iterator iter = author.begin(); iter != author.end(); ++iter)
{
cout<<iter->first<<endl; //出错
}
} 展开
1个回答
2012-02-26
展开全部
输出:
$ test.exe
Herry
Herry
Herry
Tom
Tom
不懂LZ啥意思~哪里出错了呢?
$ test.exe
Herry
Herry
Herry
Tom
Tom
不懂LZ啥意思~哪里出错了呢?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询