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.

Continue your learning journey with a 14-day free trial.

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