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 erro
What book are you using?
foreach
is not a C++ keyword, and I think the closest extension that introduces it, with that specific syntax, into the language is in Visual C++, as described in this link: http://blogs.msdn.com/b/arich/archive/2004/09/08/227139.aspx
There is for_each
in
, but its signature is very different from what you're using (which is a very Java for-each syntax).
Also I notice that you're using Map
which is different from std::map
?