Access
To access the elements of a container, you can use an iterator. If you use a begin and end iterator, you have a range, which you can further process. For a container cont
, you get with cont.begin()
the begin iterator and with cont.end()
the end iterator, which defines a half-open range. It is half-open because the begin iterator belongs to the range, the end iterator refers to a position past the range. With the iterator pair cont.begin()
and cont.end()
you can modify the elements.
Iterator | Description |
---|---|
cont.begin() and cont.end()
|
Pair of iterators to iterate forward. |
cont.cbegin() and cont.cend()
|
Pair of iterators to iterate const forward. |
cont.rbegin() and cont.rend()
|
Pair of iterators to iterate backward. |
cont.crbegin() and cont.crend()
|
Pair of iterators to iterate const backward. |
Now I...