foreach not recognized in C++

前端 未结 9 1283
离开以前
离开以前 2021-01-21 08:07

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

9条回答
  •  一向
    一向 (楼主)
    2021-01-21 08:38

    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?

提交回复
热议问题