stl 中怎样遍历一个map中的所有元素.请给是实例

如题所述

pair<int, int> pairInsert(2, 3);
map<int, int> mapTest;
mapTest.insert(pairInsert);
mapTest[3] = 5;
mapTest[6] = 5;
int xx = mapTest[4];

for (map<int, int>::iterator it=mapTest.begin(); it!=mapTest.end(); it++)
{
cout << it->second;
cout << "  ";
}

温馨提示:答案为网友推荐,仅供参考
相似回答