vector in C++ by R4R Team

What is vector data-type in C++ ?
-A vector is a sequence container class that implements dynamic array, means size automatically changes when appending elements.
-A vector stores the elements in contiguous memory locations and allocates the memory as needed at run time.

Difference between Vector and array:
-Array is static approach while vector is dynamic approach.
-Array size cannot be changed during run time while vector memory depends on numbers of elements.


#include< iostream>
#include< vector>
using namespace std;
int main()
vector< string> v1;
for(vector< string>::iterator itr=v1.begin();itr!=v1.end();++itr)
cout<<*itr<< endl;
return 0;



-In this program, we include the vector heador file that defines the vector function like push_back()
-push_back() is the function which are used to insert the data in the vector.

Leave a Comment:
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!