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

后端 未结 6 806
无人及你
无人及你 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:42

    C++11 range-based for loops aren't supported in Visual Studio 2010.

    The second form is a syntax that leaked into the compiler from C++/CLI (an entirely different language that targets the .NET runtime). I filled a bug on this a while back. If you compile with the /Za switch, it will disable this language extension. You will need to use the C++03 for loop syntax using an iterator or std::for_each.

提交回复
热议问题