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:

Level up your interview prep. Join Educative to access 80+ hands-on prep courses.