In this article we will discuss different ways to initialize a std::vector in C++.
In this article will discuss how to create 2D Matrix using vector of vectors in c++.
In this article we will discuss the iterator invalidation with respect to std::vector in C++. What is Iterator Invalidation? An Iterator becomes invalidate when the container it points to changes its shape internally i.e. move elements from one location to another and the initial iterator still points to old invalid location. Iterator invalidation in vector …
We can use vector efficiently by taking care of following points,
For User Defined classes if Copy Constructor and Assignment Operator are public then only one can insert it’s object in std::vector.
std::vector allocates a memory on heap and store all its elements in contiguous memory location.
Vector is a template based container that behaves just like a Dynamic Array.
Suppose we have a vector of integers and we want to delete all occurences of a number from it i.e.
While creating and using std::vector with user defined classes we needs some special care otherwise it can hamper the performance of our application.