What is the Difference between "vector" and "array"?

Answer Posted / mms zubeir

First, a vector is a template class but not the array is.
So obviously there are members to access the elements of
the vector like, range checking, iterators,
insertion/deletion, predicates, etc.

Since it is a template class, the same implementation can
be used for any type including pointers, objects/user
defined types.

Second, as said by others, vector automatically grow as we
invoke push_back(), we can reserve additional space for
elements, etc.

Is This Answer Correct ?    18 Yes 12 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How would you call C functions from C++ and vice versa?

854


Can we distribute function templates and class templates in object libraries?

823


Write about an iterator class?

877


What is a constant? Explain with an example.

777


What is a .h file c++?

775


Explain polymorphism?

852


Explain rtti.

841


Is swift a good first language?

809


What are shallow and deep copies?

891


What is pointer in c++ with example?

810


What is the full name of logo?

879


How can a called function determine the number of arguments that have been passed to it?

923


What are guid?

997


What are vtable and vptr?

914


Do you know what are static and dynamic type checking?

860