Priority_queue comparator class

Who will get higher priority A or B in this case and how?Can you describe it using an example?
class PersonCompare
{
public:
bool operator()(Person A,Person B)
{
return A.age<B.age;
}
};

Hi @raj_x, Comparator in priority queue take two arguments ,say a and b , then if comparator returns true that means priority of b is higher than a and vice versa , in the snippet you have provide if Person A age is less than Person B age then the function return true that means person B has higher priority, so we can say that person with more age has higher priority in this priority queue .

u can refer to this discussion for more clarity : -

In case of any doubt feel free to ask :slight_smile:
Mark your doubt as RESOLVED if you got the answer

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.