What Is a Vector?

In this lesson, we’ll be learning about 1D and 2D vectors.

Introduction to vectors

In C++, a vector is a dynamic array that can resize itself automatically when elements are added or removed. Vectors are part of the Standard Template Library (STL) and offer a convenient way to work with collections of data.

Including the vector library

To use vectors in your C++ program, include the <vector> header file:

Access this course and 1400+ top-rated courses and projects.