How does a range-based for loop work in C++11 and above? 

  • It works only on arrays and not on containers. 
  • It iterates over elements using indices. 
  • It allows iterating over all elements in a container or array directly. 
  • It requires manual initialization of iterators.
In C++11 and newer versions, the range-based for loop provides a more readable syntax to iterate over all elements of a container or an array. The loop automatically gets the begin and end iterators of the range and iterates over each element without needing manual indexing.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *