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

What are the benefits of oop in c++?

826


What is command line arguments in C++? What are its uses? Where we have to use this?

872


What is virtual base class uses?

937


What is the benefit of encapsulation?

840


Does c++ have a hash table?

747


Where is atoi defined?

798


What are protected members in c++?

882


How does a C++ structure differ from a C++ class?

869


What do you mean by function pointer?

846


How would you find out if a linked-list is a cycle or not?

758


What is struct c++?

764


Can notepad ++ run c++?

744


What is microsoft c++ redistributable 2013?

805


What are associate containers?

813


What is a volatile variable in c++?

1022