下面的这个代码实例是关于Map和makepair结合使用的一个小的方法
#include "stdafx.h"
#include<iostream>
#include<list>
#include<map>
using namespace std;
map<int,char> myMap;
int _tmain(int argc, _TCHAR* argv[])
{
myMap.insert(make_pair<int,char>(1,'A'));
myMap.insert(make_pair(2,'B'));
map<int,char>::iterator it;
it= myMap.find(2);
cout<<it->second<<endl;
it = myMap.begin();
for(;it!=myMap.end();it++)
{
cout<<it->first<<" "<<it->second<<endl;
}
system("pause");
return 0;
}
有比较详细的文章见如下:
http://blog.csdn.net/sprintfwater/article/details/8765034点击打开链接