#include#include using namespace std; int main() { priority_queue pq; pq.push(10); pq.push(20); pq.push(30); if(pq.empty()) cout << "Priority queue is empty.\n"; else cout << "Priority queue is not empty.\n"; return 0; }
Priority queue is not empty.In this example, we create a priority queue and push three elements into it. We then use the empty() function to check if the priority queue is empty. Since it is not empty, we print "Priority queue is not empty". Package library: STL (Standard Template Library)