const value_type& top() const;
const_reference top() const;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// priority_queue::top
#include <iostream> // std::cout
#include <queue> // std::priority_queue
int main ()
{
std::priority_queue<int> mypq;
mypq.push(10);
mypq.push(20);
mypq.push(15);
std::cout << "mypq.top() is now " << mypq.top() << '\n';
return 0;
}
mypq.top() is now 20