In my the cs106b book we use the expression "foreach" to go through a list of words in a Map. I implemented the code and banged my head against the wall facing mysterious errors. Here's the code:
void DisplayWordCounts(Map<int> & wordsCount) {
foreach (string word in wordsCount) {
cout << left << setw(15) << word << right << setw(5)
<< wordsCount[word] << endl;
}
}
on the line starting with "foreach" I get the following errors: lesson4-macbeth/life.cpp:58: error: expected primary-expression before 'word' lesson4-macbeth/life.cpp:58: error: 'foreach' was not declared in this scope lesson4-macbeth/life.cpp:58: error: expected `;' before '{' token
I guess foreach is not recognized. In that case, how can I go through a list of items from the Map class?