You left out a key piece of information, which is the definition of words.
However, we can deduce from your snippet that words looks like:
1 2
|
map<string,int> words;
|
It might be a little clearer if we define the iterator outside the for statement:
1 2
|
map<string,int>::iterator it; // Define an iterator for the map
|
Now, the for statement looks a little simpler.
|
for (it=words.begin(); it!=words.end(); ++it)
|
This is a vanilla for loop using an iterator. begin() returns an iterator pointing to the first element in the map. end() returns an iterator pointing past the end of the map. ++it increments the iterator for each iteration of the for loop.
A map iterator is a std::pair<const key_type, mapped_type>.
http://www.cplusplus.com/reference/utility/pair/
So we can simply use it->first and it->second to reference the string and int values in the cout statement.
maps are not stored as arrays, but it can be helpful to think of your map as an array. Your iterator starts by pointing at the first element. Each time you increment the iterator, you point to the next element until you reach the end.