Vector and array

what is the difference btw vector and array.

Following are some of the major differences:

  1. Vector is template class and are same as dynamic arrays with the ability to resize itself automatically when an element is inserted or deleted, with their storage being handled automatically by the container. On the other hand, size of arrays are fixed i.e they cannot grow and shrink as vectors are allocated on heap memory.

  2. You have to deallocat arrays explicitly if they are defined dynamically whereas vectors are automatically de-allocated from heap memory.

  3. When vector becomes larger than its capacity, reallocation is done implicitly by compiler while this doesn’t happens in case of arrays.

  4. You cannot return an array unless it is dynamically allocated, from a function whereas vectors can be returned from a function.

  5. Arrays cannot be copied or assigned directly whereas Vectors can be copied or assigned directly.

6.Being a class, there are certain functions associated with the vector that makes it efficient and easy to work with vector over array.

Hope, this would help.
If you still have doubts, feel free to ask.