C++ Standard Containers: list and vector

All the standard containers like list and vector are class templates and have the following methods in common. That is, they all have operations for adding or removing elements at the end (push_back() and pop_back()), and you can access the first and last elements directly. They also have an iterator type, which refers to elements and can be used to access each element in turn (that is, to iterate through the container.) The standard methods begin() and end() return iterators to the first element and just past the end respectively. Although string is not a full container, it also supports these methods.

 size_type size() // number of elements type back() // last element void push_back(type val); // add ...

Get C++ By Example: UnderC Learning Edition now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.