Using the Range-Based for to Display an array’s Contents

The range-based for statement simplifies the code for iterating through an array. Line 13 can be read as “for each iteration, assign the next element of items to int variable item, then execute the following statement.” Thus, for each iteration, identifier item represents one element in items. Lines 13–14 are equivalent to the following counter-controlled repetition:

for ( int counter = 0; counter < items.size(); ++counter )
   cout << items[ counter ] << " ";

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.162.247