Answers for "vector erase specific element"

C++
5

vector erase specific element

vector.erase( vector.begin() + 3 ); // Deleting the fourth element
Posted by: Guest on July-05-2020
-2

vector erase specific element

template <typename T>
void remove(std::vector<T>& vec, size_t pos)
{
    std::vector<T>::iterator it = vec.begin();
    std::advance(it, pos);
    vec.erase(it);
}
Posted by: Guest on July-05-2020

Code answers related to "vector erase specific element"

Browse Popular Code Answers by Language