Skip to content

Commit c6fa042

Browse files
authored
Merge pull request codewithdev#70 from adityap301/master
Added erase() of vectors
2 parents 87dd53a + 178f733 commit c6fa042

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

08-Vector/erase.cpp

Lines changed: 14 additions & 0 deletions
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)