Page MenuHomePhabricator

Does C++ have a for loop similiar to that of Pythons foreach loop?
Closed, ResolvedPublic

Asked by nsgroggett on Jun 8 2017, 7:17 PM.
"Like" token, awarded by jcmcdonald.


The foreach loop in Python is an incredibly useful function in python and it would be useful to have that in C++.

Answer Summary

In fact, C++ does have foreach loops, Though it is slightly different from what Pythons does. In addition since C++ 11 for loops have added extra functionality so that they can behave like Python's foreach. The following are links to both examples and descriptions of the new functionality of for in c++.

ranged based for


New Answer


This question has been marked as closed, but you can still leave a new answer.