3.4.1. Using Iterators
Unlike pointers, we do not use the address-of operator to obtain an iterator. Instead, types that have iterators have members that return iterators. In particular, these types have members named begin
and end
. The begin
member returns an iterator that denotes the first element (or first character), if there is one:
// the compiler determines the type of b and e; see § 2.5.2 (p. 68)// b denotes the first element and e denotes one past the last element in vauto b = v.begin(), e = v.end(); // b and e have the same type
The iterator returned by end
is an iterator positioned “one past the end” of the associated container (or ...
Get C++ Primer, Fifth Edition 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.