The type lol
needs an operator<
function so that the priority_queue
knows how to sort them. The compiler doesn't provide one by default. There are a few options.
To get the code to compile without changing the declaration of priority_queue<lol> q;
you will need to provide the operator. You can declare it as a free function. Here's an example; assuming you would sort a lol
struct based on the num1
field (not sure how you actually want to do it).
bool operator< (const lol &left, const lol &right) {
return left.num1 < right.num1;
}
Note, if num1
was private, you'd need to make the operator a friend of lol
.