July 2015
Intermediate to advanced
558 pages
13h 31m
English
Range-based for-loops are another syntactic convenience introduced in C++11. Range-based for-loops allow you to iterate through a sequence of values like arrays, containers, iterator ranges, and so on, without having to explicitly specify boundary conditions. It makes iterating less error-prone by obviating the need to specify boundary conditions.
The general syntax for range-based for-loop is:
for (range-declaration : sequence-expression) { statements; }
The sequence expression identifies a sequence of values like an array or a container, that is to be iterated through. The range declaration identifies a variable that would represent each element from the sequence in successive iterations of the loop. Range-based for-loops ...
Read now
Unlock full access