What is queue.pop() in C++?
The queue.pop() function in C++ removes the element that is available at the front of the queue.
Figure 1 shows the visual representation of the queue.pop() function.
In order to use the queue.pop() function, we must include queue in the program as shown below.
#include <queue>
Syntax
queue_name.pop()
// where the queue_name is the name of the queue
Parameter
This function does not require a parameter.
Return value
This function returns the element that is available at the front of the queue and removes that element from the queue.
Example
#include <iostream>//header file#include <queue>using namespace std;int main() {queue<int> queue1;queue1.push(1);queue1.push(3);queue1.push(5);queue1.push(2);queue1.push(0);//queue1 = 1->3->5->2->0cout<<"The length of queue before pop: \n"<<queue1.size()<<"\n";queue1.pop();//after the pop queue1 = 3->5->2->0cout<<"The length of queue after pop: \n"<<queue1.size();}