How can I remove an element at a specified index in a vector, and then return that element?
Is there a method for that?
How can I remove an element at a specified index in a vector, and
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.
erasecan remove an element at a specified index, but does not return that element.You can just do:
Be careful though, vectors are not good at removing elements that aren’t at the end of the vector. This can be a costly operation for large vectors.