C ++ method to traverse map
C ++ is required to access the container iterators instead of the subscript.
c++98
map<string, int>::iterator it;
for (it = m2.begin(); it != m2.end(); it++) {
string s = it->first;
printf("%s %d\n", s.data(), it->second);
}
c ++ after 11
for(auto it : map1){
cout << it.first <<" "<< it.second <<endl;
}