Remove Vector elements by position

Hi,

How can i remove the vector elements by position,like

MyVect.erase (MyVect.at(1));

thanks in advance
MyVect.erase( MyVect.begin() + 1 );
erase() takes an iterator to the element to be deleted as argument. You can use begin() to get an iterator to the first element in the vector. You can then use operator+ on the iterator to make it point to a certain object.

This code will erase element at position i:
MyVect.erase(MyVect.begin() + i);
Topic archived. No new replies allowed.