Vector Pop Back in C++
Level 266 keystrokes
Removes the last element of the vector {1, 2, 3} with pop_back() and prints the new size, 2.
C++ code
// Creates a vector with three elements1vector<int> v = {1, 2, 3};// pop_back() removes the last element (3), leaving {1, 2}// It returns nothing, so read back() first if you need the value2v.pop_back();// Prints the new size, 23cout << v.size() << endl;Output
2
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this C++ code and how often they appear.
<× 5;× 3,× 2.× 2(× 2)× 2_× 1{× 1}× 1=× 1