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方法内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复