English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
C ++ The pop_back() function of List removes the last element from the list and reduces the size of the list by one.
The pop_back() function deletes the last element, that is4
void pop_back();
It does not contain any parameters.
It does not return any value.
Let's look at a simple example
#include <iostream> #include<list> using namespace std; int main() { list li={6,7,8,9}; list::iterator itr; li.pop_back(); li.pop_back(); for(itr=li.begin();itr!=li.end();++itr){ cout<<*itr<<","; } return 0; }
Output:
6,7
In this example, the pop_back() function removes the last two elements from the list.