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

Why is c++ awesome?

785


Why do we need c++?

767


What is the difference between strcpy() and strncpy()?

829


What is the difference between an array and a list?

753


What is the use of typedef?

815






What do you mean by static variables?

816


What are the general quetions are in DEna bank manager IT/System interviews?

1756


What is lvalue?

902


What is class definition in c++ ?

806


What is static class data?

755


Does c++ support exception handling?

775


Can a program run without main in c++?

805


What information can an exception contain?

862


What c++ is used for?

812


What will the line of code below print out and why?

504