Skip to content

Commit 178f733

Browse files
committed
Added erase() of vectors
1 parent 80cae8c commit 178f733

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

08-Vector/erase.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include<iostream>
2+
#include<vector>
3+
using namespace std;
4+
int main()
5+
{
6+
vector<int>v{1, 2, 3, 4, 5, 14};
7+
vector<int>::iterator it;
8+
// Delete last element
9+
it = v.end()-1;
10+
v.erase(it);
11+
for (int x:v) {
12+
cout<<x<< ",";
13+
}
14+
}

0 commit comments

Comments
 (0)