C++ Language/ProgramFlow/Loops/LoopingOverCollection

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Any STL collection that provides iterators via begin() and end() (e.g., std::vector<int> veciVar = {0,11,22,33};) can be iterated by for (int iItem : veciVar) { body }.

Additional information about looping over a collection (includes interactive examples)