I have a std::map mymap
Now, if I insert values in the map like:
std::map mymap;
mymap[\"first\"] = \"hi\";
mymap[\"third\"] = \"
The elements in std::map
are ordered (by default) by operator<
applied to the key.
The code you posted, with minor edits, worked for me as you expected:
std::map mymap;
mymap["first"]="hi";
mymap["third"]="how r you";
mymap["second"]="hello";
for (std::map::iterator i = mymap.begin(); i != mymap.end(); i++)
{
cout << i->second << "\n";
}
Prints:
hi
hello
how r you