Control Structures in C++: Range-based for Loops
One of the many differences between modern C++ and classic C++ is the presence of range-based for loops. These were added to the standard in C++11 and allow for loops to iterate easily over a container and reduce the risk of off-by-one errors. They also eliminate the need for an integer index variable to index into a container. Start this course by reviewing how for loops work to iterate over arrays. Create arrays with different numbers of dimensions and iterate over the dimensions using nested for loops. Discover how to use containers from the standard template library to experiment with maps and vectors. Explore the use of the cbegin() cend() rbegin() rend() crbegin() and crend() functions. Finally use range-based for loops and explore the use of the debugger in this context. You will also note the important differences between value type loop variables in for loops and reference type variables.