English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
C ++ List push_back() inserts a new element at the end of the list, and the size of the list container increases1.
The push_back() function inserts elements at the end5.
Assuming an element is " x":
push_back(const value_type& x);
x: It is the end of the value to be inserted.
It does not return any value.
Let's see a simple example
#include<iostream> #include<list> using namespace std; int main() { listli={"C"," .Net"++," .Net "]; list::iterator itr; li.push_back(" java "); li.push_back(" PHP "); for(itr=li.begin();itr!=li.end();++itr) cout<<*itr; return 0; }
Output:
C C++ .Net java PHP
In this example, the push_back() function inserts two strings, java and PHP, at the end of the list.
Let's see a simple example
#include<iostream> #include<list> using namespace std; int main() { list li={6,7,8,9}; list::iterator itr; li.push_back(10); li.push_back(11); for(itr=li.begin();itr!=li.end();++itr) cout<<*itr<<"," return 0; }
Output:
6,7,8,9,10,11