-1

I am doing the codecademy c++ course and just went over vectors and arrays. From what I understand, the only difference between the two is that you can change the size of a vector, but cannot change the size of an array. Are there any other differences that I am missing that would make them more useful in the future?

1 Answers1

2

A major difference is that std::vector allocates memory, i.e. it uses the heap for storage. An array (std::array or a built-in one) does not.

Allocating memory is a major difference because it is a very expensive operation relative to many others (when using the default allocator).

Acorn
  • 24,970
  • 5
  • 40
  • 69