Details
Details
The foreach loop in Python is an incredibly useful function in python and it would be useful to have that in C++.
Answer Summary
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
http://en.cppreference.com/w/cpp/language/range-for
for_each
http://en.cppreference.com/w/cpp/algorithm/for_each
New Answer
New Answer