The pop method in a C++ priority_queue is employed to eliminate the highest priority element from the queue. It is possible to access the value of this element prior to removal by using the top function.
Syntax
Consider the priorityqueue 'pq' as an instance of a priorityqueue object.
Example
pq.pop ();
Parameter
It does not take any parameter.
Return value
Example 1
Example
#include <iostream>
#include <queue>
using namespace std;
int main()
{
priority_queue<int> mp;
mp.push(10);
mp.push(25);
mp.push(30);
mp.push(35);
mp.push(40);
cout<< "poping element ";
while(!mp.empty())
{
cout<< ' ' <<mp.top();
mp.pop();
}
return 0;
}
Output:
Output
poping element 40 35 30 25 10