std::vector V
contains elements a1, a2 ,a3, a4, a5, a6
and I need to copy elements from a2
to a4
in a new std::vector NV
.
How is it possible to copy range of vector into a new vector? i did this uin my code as per recommendations but still i am not able to figure out?The part involved is this one.
vector<int>::const_iterator first = v.begin() + i+1;
vector <int>::const_iterator last = v.begin() + i+k;
vector<int>:: nv(first, last);