1vector.erase(position) // remove certain position
2// or
3vector.erase(left,right) // remove positions within range
4
1#include<bits/stdc++.h>
2using namespace std;
3int main(){
4 vector<int> v;
5 //Insert values 1 to 10
6 v.push_back(20);
7 v.push_back(10);
8 v.push_back(30);
9 v.push_back(20);
10 v.push_back(40);
11 v.push_back(20);
12 v.push_back(10);
13
14 vector<int>::iterator new_end;
15 new_end = remove(v.begin(), v.end(), 20);
16
17 for(int i=0;i<v.size(); i++){
18 cout << v[i] << " ";
19 }
20 //Prints [10 30 40 10]
21 return 0;
22}
23C++Copy