is a collection of objects, all of which have the same type. Every object in the collection has an associated index, which gives access to that object. A
vector is often referred to as a container because it “contains” other objects. We’ll have much more to say about containers in Part II.
To use a
vector, we must include the appropriate header. In our examples, we also assume that an appropriate
using declaration is made:
#include <vector>using std::vector;
vector is a class template. C++ has both class and function templates. Writing a template requires a fairly deep understanding of C++. Indeed, we won’t ...