English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

C++ Usage and example of pop_front() function

C++ List (List)

C ++ The pop_front() function removes the first element from the list, so the size of the list will decrease by one.

The pop_front() function removes the first element, that is1.

Syntax

void pop_front();

Parameters

It does not contain any parameters.

Return value

It does not return any value.

Example

Let's look at a simple example

#include <iostream>  
#include<list>  
using namespace std;  
int main()
{
     list li={20,30,40,50};
    li.pop_front();
    list::iterator itr;
    for(itr=li.begin();itr!=li.end();++itr)
    cout<<*itr<<",";
    return 0;
}

Output:

30,40,50

In this example, the pop_front() function removes the first element from the list, i.e., removes the element " 20.

C++ List (List)