Vector 2.1

Vector in C++ STL


Vector is same as array type variable. But in vector, not necessary to define the size. So, when input size is unknown to you then you can use vector. There are several build in functions in vector. Again, you need to use push_back to take vector input. You can define various data type vector, such as: int, double, float, string.

What is the difference between Vector and Array?

- Vector is a dynamic array structure. Actually, vector is a dynamic link list
- We don't need to define size at the time of initialization
- Any time we can delete any items and the vector size will be decreased automatically. However, if we delete any item in array, it will still contain that memory space.
- Array gives better performance in speed than vector.

References:
www.cplusplus.com/
https://sites.google.com/site/smilitude/

মন্তব্যসমূহ