c++11 auto

来源:互联网 发布:办公软件应用教程 编辑:程序博客网 时间:2024/06/04 18:05

在遍历容器时需要用到iterator,

std::map<std::string, std::vector<int>> map;for(auto it = begin(map); it != end(map); ++it) {}


可以用auto遍历map

for (auto &kv : myMap) {    count<<kv.first<<" has value "<<kv.second<<endl;}


0 0
原创粉丝点击