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 the difference between new() and malloc() in c++?

634


What is the purpose of template?

622


What is the difference between a baller and a reference in C++?

586


How do you generate a random number in c++?

614


Give 10 points of differences between C & C++.

637






What is c++ iterator?

653


What is iomanip c++?

606


What kind of problems can be solved by a namespace?

601


What is a container class? What are the types of container classes in c++?

685


What are references in c++? What is a local reference?

580


Explain linear search.

645


How are Structure passing and returning implemented by the compiler?

606


What is class syntax c++?

611


Mention the ways in which parameterized can be invoked.

550


What is the difference between an external iterator and an internal iterator? Describe an advantage of the external iterator.

570