Compilation error with “for each” loop in C++ VS2010

后端 未结 6 821
无人及你
无人及你 2021-01-21 10:29

I was working on a little C++ project at home, which I brought into school to show my teacher. At home I have Visual Studio 2012, whereas the school computers have Visual Studio

6条回答
  •  不知归路
    2021-01-21 10:34

    The "range for" is a C++ 11 feature that was added in Visual Studio 2012. To learn more about which C++ 11 features are in Visual Studio 2008 (VC9) and Visual Studio 2010 (VC10), check the blog entry from the Visual C++ team. There are similar tables to let you know about Visual Studio 2012 and several different releases of Visual Studio 2013.

    Bottom line: your for loop that you did at home is great if you have Visual Studio 2012. If you don't, use a regular for or std::for_each, not the for each you're using there.

提交回复
热议问题