简体   繁体   中英

Basic c++ : for-each loop

I have been learning C++ for a couple of weeks, and am sorry for my basic question but this question seems too hard to find its answers to in google or on this SO site. I am learning to code modern C++ in VS 2015 and I can do something like this (my friend's code)

for each (int i in vectorOfInt)
{
   // do something
}

But after searching a lot from this http://en.cppreference.com/

I still can't find its syntax. I asked him and he said, his teacher wrote so. Is it part of C++? Since when it becomes available? As I can't find it in my latest C++ book (Bjarne's) also.

This is a non-standard microsoft extension for C++ and C++/CLI

for each, in

Iterates through an array or collection. This non-standard keyword is available in both C++/CLI and native C++ projects. However, its use is not recommended. Consider using a standard Range-based for Statement (C++) instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM