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

Explain register storage specifier.

590


Can constructor be static in c++?

641


Is swift faster than go?

615


What are stacks? Give an example where they are useful.

594


Differentiate between an inspector and a mutator ?

705






Write a note about the virtual member function?

603


Is oops and c++ same?

578


What is scope operator in c++?

565


Explain the extern storage classes in c++.

552


What do you mean by inheritance in c++? Explain its types.

610


Specify some guidelines that should be followed while overloading operators?

618


Can a program run without main?

629


What is fflush c++?

576


What is an object in c++?

612


How a pointer differs from a reference?

692