在遍历容器时需要用到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;
}
在遍历容器时需要用到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;
}