
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Advantages of Vector Over Array in C++
Vector is a template class and is C++ only construct whereas arrays are built-in language construct and present in both C and C++.
Vector are implemented as dynamic arrays with list interface whereas arrays can be implemented as statically or dynamically with primitive data type interface.
Differences between a Vector and an Array
A vector is a dynamic array, whose size can be increased, whereas THE array size can not be changed.
Reserve space can be given for vector, whereas for arrays you cannot give reserved space.
A vector is a class whereas an array is a datatype.
Vectors can store any type of objects, whereas an array can store only homogeneous values.
Advantages of Arrays
Arrays support efficient random access to the members.
It is easy to sort an array.
They are more appropriate for storing a fixed number of elements
Disadvantages of Arrays
Elements can not be deleted
Dynamic creation of arrays is not possible
Multiple data types can not 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.