I want to traverse an STL map. I don\'t want to use its key. I don\'t care about the ordering, I just look for a way to access all elements it contains. How can I do this?
You can iterate map by using auto iterator.
#include using namespace std; int main() { ios::sync_with_stdio(false); map mp; mp["a"]=500; mp["b"]=200; mp["d"]=300; mp["c"]=400; for(auto it=mp.begin(); it != mp.end(); it++) { cout<first <<" : "<second<