... integers2 to function inputVector (lines 104–108) to read values for each vector’s elements from the user. The function uses a range-based for statement with a range variable that’s a reference to an int. Because the range variable is a reference to a vector element, the reference can be used t store a input value in the corresponding element.

Comparing vector Objects for Inequality

Line 40 demonstrates that vector objects can be compared with one another using the != operator. If the contents of two vectors are not equal, the operator returns true; otherwise, it returns false.

Initializing One vector with the Contents of Another

The C++ Standard Library class template vector allows you to create a new vector object that’s initialized with ...

Get C++ How to Program, 10/e now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.