What is the Difference between "vector" and "array"?

Answers were Sorted based on User's Feedback



What is the Difference between "vector" and "array"?..

Answer / vivek

in vector space is not fixed,but in array space is fixed
second vector has memory allocation is dynamic which is
unsuitable at execution time but in array memory allocation
is continuously
array contain same datatype it is not in vector
array has compatibility to use 2d,3d arrayalso

Is This Answer Correct ?    3 Yes 1 No

What is the Difference between "vector" and "array"?..

Answer / sumit arora

In C++,vectors are used for dynamically allocating space
(run time)as per your need,you do not need to hard code for
eg: consider a <vector> v;
for(int i=0;i<=v.size();i++)
cout<<v[i];

and that size can be increased with v.pushback(element)for
eg.
so there is no need to hard code whatever element you
pushed back only that memory is used.

but in array you do only have a fixed size
for(i=0;i<=100;i++)
cin<<a[i];

and if you want to access a[101] positions also it will
show you a garbage value ,bcoz in array there is no bound
checking and memorywize its a compile time allocation not a
dynamic one.

Is This Answer Correct ?    2 Yes 0 No

What is the Difference between "vector" and "array"?..

Answer / ...........

difference of vector and array in data structure

Is This Answer Correct ?    1 Yes 0 No

What is the Difference between "vector" and "array"?..

Answer / maninder kaur

what is difference between vector class and array?

Is This Answer Correct ?    2 Yes 2 No

What is the Difference between "vector" and "array"?..

Answer / musaddique

arrat is derived type But vector is user-defined type or
class type

Is This Answer Correct ?    8 Yes 13 No

Post New Answer

More C++ General Interview Questions

To which numbering system can the binary number 1101100100111100 be easily converted to?

0 Answers  


Am pass the 10000 records to target in target I will take commit interval 15000 when I was stop the work flow what will happened

0 Answers  


Is c++ a pure oop language?

0 Answers  


What is the identity function in c++? How is it useful?

0 Answers  


what is data Abstraction

2 Answers  






Why null pointer is used?

0 Answers  


what is object?

7 Answers  


Is there any function that can skip certain number of characters present in the input stream?

0 Answers  


How we can differentiate between a pre and post increment operators during overloading?

0 Answers  


Explain the differences between list x; & list x();.

0 Answers  


Do we have to use initialization list in spite of the assignment in constructors?

0 Answers  


How the V-Table mechanism works?

6 Answers   HP,


Categories