vector <map<string,string>> dictionary;
map <string, string> word1;
map <string, string> word2;
word1.insert(pair<string, string>("UNREAL","Abc"));
word2.insert(pair<string, string>("PROPS","Efg"));
dictionary.push_back(word1);
dictionary.push_back(word2);
vector<map<string, string>>::iterator it;
it = dictionary.begin();
for( it; it != dictionary.end(); it++)
{
cout << it << " " << it << endl; //ERROR
}
我想显示存储在向量中的数据。请建议我如何显示矢量字典的输出?
原文由 Sunil Singh 发布,翻译遵循 CC BY-SA 4.0 许可协议
为了解决您的问题,您应该这样做:
但是,我认为设计有问题。 In your case you do not need
vector
ofmap
s… you needvector
ofpair
s or just amap
。对向量:
地图:
因为 map 不仅仅是一对东西,它是一组对(有点不准确)。