how to erase then insert element in a vector c++ code example
Example 1: vector erase specific element
vector.erase( vector.begin() + 3 ); // Deleting the fourth element
Example 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);
}