I am trying to create a priority queue consisting of pairs of int, char that gives me the pair with the greater int, but my code is not working properly. What am I doing wrong?
This is my comparator class:
class Compare
{
public:
bool operator() (pair<int, char>a, pair<int, char>b)
{
return a.first > b.first;
}
};
And this is my priority queue:
priority_queue<pair<int, char>, vector<pair<int, char>>, Compare> party;
But if I execute the code:
party.push(make_pair(2, 'A'));
party.push(make_pair(3, 'B'));
cout<<party.top().first;
It returns 2, instead of 3. How do I fix my implementation of the priority queue?