我在迭代 map 中的第二张 map 时遇到问题。
#include <map>
using namespace std;
map<string, map<string, string> > mymap;
map<string, map<string, string> >::iterator itm;
pair<map<string, map<string, string> >::iterator,bool> retm;
for( itm=mymap.begin(); itm!=mymap.end(); ++itm)
{
cout << "first:\t" << it->first << endl;
}
如何遍历第二个映射并获取第一个和第二个键/值?
第二个问题是,如何使用 map 自带的“插入”功能“插入”到第一张和第二张 map 中?
我希望有人能给出完整的答案。
最佳答案
it->second
会给你“第二张 map ”。只需迭代即可。
关于c++ - 在 map 中迭代 map ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12600840/