1#include <vector>
2
3int main() {
4 std::vector<int> v;
5 v.push_back(10); // v = [10];
6 v.push_back(20); // v = [10, 20];
7
8 v.pop_back(); // v = [10];
9 v.push_back(30); // v = [10, 30];
10
11 auto it = v.begin();
12 int x = *it; // x = 10;
13 ++it;
14 int y = *it; // y = 30
15 ++it;
16 bool is_end = it == v.end(); // is_end = true
17
18 return 0;
19}
1 Vector functions in C++
2 --------------------
3 clear() // remove all the elements of the vector container
4 insert() // Inserts new elements before the element at the specified position
5 emplace() // Extends the container by inserting new element at position
6 erase() // Remove elements from a container from the specified position or range
7 push_back() // Push the elements into a vector from the back
8 emplace_back() // Constructs an element in-place at the end
9 pop_back() // Pop or remove elements from a vector from the back
10 resize() // Changes the number of elements stored
11 swap() // Swap the contents of one vector with another vector of same type. Sizes may differ.