Array vs. Vector
- A vector is a dynamic array, whose size can be increased, where as an array size can not be changed.
- Reserve space can be given for vector, where as for arrays can not.
- A vector is a class where as an array is not.
- Vectors can store any type of objects (without generics) , where as an array can store only homogeneous values.
Advantages and Disadvantages
Advantages of Arrays
- Arrays supports efficient random access to the members.
- It is easy to sort an array.
- They are more appropriate for storing fixed number of elements
Disadvantages of Arrays
- Elements can not be deleted
- Dynamic creation of arrays is not possible
- Multiple data types cannot be stored
Advantages of Vector
- Size of the vector can be changed
- Multiple objects can be stored
- Elements can be deleted from a vector
Disadvantages of Vector
- A vector is an object , memory consumption is more.
No comments:
Post a Comment
Note: only a member of this blog may post a comment.