Векторы — это часть stl в C++, которая была разработана для облегчения жизни программиста.

Они содержат некоторые функции, с помощью которых вы можете вносить изменения в вектор. Векторы являются динамическими и могут хранить значения без указания их предыдущего размера.

#include <vector>

СИНТАКСИС

vector<int> g1; //Initialized the vector

v.assign(5, 10); // fill the array with 10 five times replacing old

g1.push_back(i); // Enter the value at the end of the vector

v.pop_back() //Deletes the last element from the vector

v.insert(v.begin(), 5); // Insert value 5 to the begin position

v.erase(v.begin()) //It is used to delete the element from container

v.clear(); //It erases the vector

g1.at(4) // Returns the value of the vector at position 4

g1.front() // Returns the first Element

g1.back() //Returns the last Element

g1[0] //Elements can be accessed like array

g1.size() //Returns the size of the vector

v1.swap(v2); //Swaps two vectors

g1.begin() //Returns the pointer pointing the first position

g1.end() // Returns the pointer pointing to the last element

g1.capacity() // Returns the current capacity of the vector

g1.max_size() //Returns the max size of the vector

g1.resize(4) // Remove the last elements and changes the size

g1.empty() //Checks if the vector is empty3

vector<int> name(size) //if you want to provide a size

Библиография



https://syntaxdb.com/ref/cpp/vectors