Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

initialize vector

// Create an empty vector
vector<int> vect;

// Create a vector of size n with all values as 10.
vector<int> vect(n, 10);

//initilize with values
vector<int> vect{ 10, 20, 30 };

//initilize with old array
vector<int> vect(arr, arr + n);

//initilize with old vector
vector<int> vect2(vect1.begin(), vect1.end());
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #initialize #vector
ADD COMMENT
Topic
Name
3+5 =