I am inserting key value pairs in a std::map
as
key = //something;
value = //something;
demoMap[key] = value;
Printing the key and value here gives me correct results. However, when I iterate this map as:
for( std::map<std::string, std::string>::iterator it = demoMap.begin();
it != demoMap.end(); it++ ) {
std::cout << it->first + "," << it->second;
}
Using above iteration, I get the second key value pair printed before the first one. Why is it so? The first key value pair should be printed first since the iterator of the map is set to begin()
for the map.