![]() |
VOOZH | about |
In C++, the vector push_back() is a built-in method used to add a new element at the end of the vector. It automatically resizes the vector if there is not enough space to accommodate the new element.
Let’s take a look at an example that illustrates the vector push_back() method:
1 4 6 9
This article covers the syntax, usage, and common examples of the vector push_back() method in C++:
Table of Content
The vector push_back() is a member method of the std::vector class defined inside the <vector> header file.
v.push_back(val);
Parameters:
Return Value:
The following examples demonstrate the use of the vector push_back() function for different purposes:
3 7 9
Hello Geeks Welcome