Chapter 29. Using Iterators and Containers

<feature>
  • Learn about iterators and why they’re useful

  • Explore iterator operations and classes

  • See the differences between sequence containers and associative containers

  • Examine the standard container classes

</feature>

Understanding Iterators

Iterators and containers are closely related. Conceptually, an iterator is something that an algorithm can use to traverse the sequence of objects in a container; an iterator knows how to iterate through the contents of a container. Standard Template Library (STL) container classes such as vector, list, and map all use iterators to represent container elements. The generic algorithms provided by the standard library work with the generic containers, but not all algorithms ...

Get Practical C++ 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.