South Africa’s biggest forum. Discuss, discover, and connect with thousands of members.
Aaah I see what you mean. I think that's exactly what the exercise meant. Will give it a shot tomorrow.
PS : Would I need to use 2 for loops to iterate through the map then?
Instead of using iters you can use .find on the map which will return you the other map.
You still have to iterate through the inner map.
So the iteration would be something like
my_map<string, int>::iterator inner;
my_map::iterator find_value = my_map.find(a);
for ( inner = find_value -> second.begin(); inner != find_value -> second.end(); inner++ )
{
cout << find_value -> first << inner -> first << inner -> second;
}
That's more or less how I did it this morning. But thanks, your idea solved it for me.