Resizing a Vector

This lesson teaches how a vector can be resized or how it can grow and shrink.

Add Elements to the Vector

  • Define a mutable vector variable.
  • To add elements to the vector, use the push method.

The following illustration shows how the size of the vector grows by adding an element:

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy