what goes in the 2nd parameter of the function? Is it the number of elements to be deleted from index i or the last index until which we have to delete elements?
v.erase(v.begin()+2,v.begin()+5);
what does 5 mean here…
what goes in the 2nd parameter of the function? Is it the number of elements to be deleted from index i or the last index until which we have to delete elements?
v.erase(v.begin()+2,v.begin()+5);
what does 5 mean here…
@sh3rlock first argument points to the starting element (inclusive) and second argument is the ending element (exclusive)
so v.erase(v.begin()+2,v.begin()+5);
means that v[2] to v[4]
will be erased from the vector.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.