Q:

how to create a vector from elements of an existing vector in cpp

// Initializing vector with values 
    vector<int> vect1{1, 2, 3, 4}; 
  
    // Declaring another vector 
    vector<int> vect2; 
  
    // Copying vector by assign function 
    vect2.assign(vect1.begin(), vect1.end()); 
0

New to Communities?

Join the community