// Using a priority_queue // Ken Moore 2003 #pragma warning(disable : 4786) #include #include #include using namespace std; // function object comparator template// templating is optional struct comp{ bool operator()(const T &a,const T &b)const{ // least to greatest //return b, comp > pq; // reverse default order //priority_queue, greater > pq; // uses the less function and gives reverse order //priority_queue pq; pq.push(987); pq.push(9); pq.push(98742); pq.push(98); while(!pq.empty()) { cout << pq.top() << "\n"; pq.pop(); } }