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
What is a string example?
What is c++ hash?
What are the rules for naming an identifier?
How would you implement a substr() function that extracts a sub string from a given string?
How do you print a string on the printer?
What does #define mean in c++?
How do you declare A pointer to function which receives an int pointer and returns a float pointer
Can you overload the operator+ for short integers?
How do we balance an AVL Tree in C++?
Explain how a pointer to function can be declared in C++?
Can java be faster than c++?
Do class method definitions?
What are the c++ access specifiers?
What is using namespace std in c++?
Is java made in c++?