I have a vector contains a,b,c,d,e
vec[2] is c, but will it automatically reorder after i delete/erase c ? i mean vec[2] is d after the operation.
I have a vector contains a,b,c,d,e vec[2] is c, but will it automatically reorder
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Logically yes, as a vector is a dynamic array of element. You delete one, then everything that follows is moved.
In the same manner, the total length of the vector will decrease as you erase elements.
From cplusplus.com