list push_back() function in C++ STL

The list:push_back() function in C++ STL is used to add a new element to an existing list container. It takes the element to be added as a parameter and adds it to the list container.



Parameters: This function accepts a single parameter which is mandatory value. This refers to the element needed to be added to the list, list_name.

Return Value: The return type of this function is void and it does not returns any value.

Below program illustrates the list::push_back() function.





// CPP program to illustrate the
// list::push_back() function
#include <bits/stdc++.h>
using namespace std;
int main()
    // Initialization of list
    list<int> demo_list;
    // intital size of list
    cout << "Initial Size of the list: "
         << demo_list.size() << endl;
    // Adding elements to the list
    // using push_back function
    // Size of list after adding
    // some elements
    cout << "Size of list after adding three "
         << "elements: " << demo_list.size();
    return 0;



Initial Size of the list: 0
Size of list after adding three elements: 3

Rated as one of the most sought after skills in the industry, own the basics of coding with our C++ STL Course and master the very concepts by intense problem-solving.

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using or mail your article to See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :
Practice Tags :


Please write to us at to report any issue with the above content.