how to delete last element of vector c++ code example
Example 1: c++ vector pop_back
#include <bits/stdc++.h>
using namespace std;
int main(){
vector<int> v1{10, 20, 30, 40, 50};
//removing elemenets
v1.pop_back(); //removes 50
v1.pop_back(); //removes 40
}
Example 2: pop_back
Removes the last element of the vector
Example 3: c++ remove last element from vector
vector.pop_back();
Example 4: remove the last element of a vector in cpp
vectorname.pop_back();