vector.erase( vector.begin() + 3 ); // Deleting the fourth element
//me
vec.erase(vec.begin() + index); //index 0 means first element and so on
#include <vector>
#include <algorithm>
#include <iostream>
int main()
{
//C++20 std::erase function wraps erase-remove idiom
std::vector<int> ivec{ 1, 5, 7, 2, 1, 3, 1, 7, 1 };
auto n = erase(ivec, 1); //ADL
std::cout << n << " elements erased
";
for (auto i : ivec)
std::cout << i << ' ';
}
vector.erase(position) // remove certain position
// or
vector.erase(left,right) // remove positions within range
remove(v.begin(),v.end(),val)