2个回答
展开全部
举个例子吧:
map<string,map<string,string>> myMap;
map<string,string> childMap1;
childMap1.insert("childMap1item1","item1");
childMap1["chileMap1item2"]="item2";//若没找到key为chileMap1item2的元素就则添加一个
map<string,string> childMap2;
childMap2.insert(map<sting, string>::value_type("childMap2item1","item1"));
myMap.insert("childMap1",childMap1);
myMap.insert("childMap2",childMap2);
//若想从myMap中找到childMap1的key为"chileMap1item2"的元素,可以这么做
map<string,map<string,string>>::iterator it = myMap.find("childMap1");
map<string,string>::iterator childIterator = it->second.find("chileMap1item2");
string value=childIterator->second;//value即为所求值
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询