c++ string pop_back code example
Example 1: remove last character from string c++
st = myString.substr(0, myString.size()-1);
Example 2: 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 3: c++ list pop back
void pop_back();
// desc: remove last element. complexity: constant