... vector
’s first and last elements, respectively. Notice the difference between functions front
and begin
. Function front
returns a reference to the first element in the vector
, while function begin
returns a random-access iterator pointing to the first element in the vector
. Also notice the difference between functions back
and end
. Function back
returns a reference to the vector
’s last element, whereas function end
returns a random access iterator pointing to the location after the last element.
Common Programming Error 15.2
The results of front
and back
are undefined when called on an empty vector
.
Accessing vector
Elements
Lines 23–24 illustrate ...
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.