我是靠谱客的博主 故意冷风,这篇文章主要介绍C++遍历map方法C++遍历map方法,现在分享给大家,希望可以做个参考。

C++遍历map方法

C++中访问容器需要使用迭代器,而非下标。

c++98


map<string, int>::iterator it;
for (it = m2.begin(); it != m2.end(); it++) {
string s = it->first;
printf("%s %dn", s.data(), it->second);
}

c++11以后

for(auto it : map1){
cout << it.first <<" "<< it.second <<endl;
}

最后

以上就是故意冷风最近收集整理的关于C++遍历map方法C++遍历map方法的全部内容,更多相关C++遍历map方法C++遍历map方法内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(133)

评论列表共有 0 条评论

立即
投稿
返回
顶部