top

C++ Reference

top
Syntax:
  #include <queue>
  TYPE& top();

The function top() returns a reference to the top element of the priority queue.

For example, the following code removes all of the elements from a stack and uses top() to display them:

   while( !s.empty() ) {
     cout << s.top() << " ";
     s.pop();
   }            
Related topics: