简介
========================================================================================
- 与其他容器一样,map容器同样提供begin和end运算,以生成用于遍历整个容器的迭代器。
map<string,int>::const_iterator map_it = word_count.begin();
while(map_it!=word_count.end()){
cout<<map_it->first<<endl;
cout<<map_it->second<<endl;
++map_it;
}
- 这个单词统计程序依据字典顺序输出单词,在使用迭代器遍历map 容器时,迭代器指向的元素按键的升序排列。

1万+

被折叠的 条评论
为什么被折叠?



