I am trying to make a priority queue of a class I made like this –
std::priority_queue<Position> nodes;
I overloaded the < operator in Position like this –
bool Position::operator<(Position& right) {
return (fvalue < right.getFValue());
}
However, whenever I try to compile I get this error message saying the < operator is not overloaded –
error: no match for ‘operator<’ in ‘__x < __y’
position.h:30: note: candidates are: bool Position::operator<(Position&)
What am I missing here? Any help is appreciated.
Relational operators shouldn’t change the operands. Try:
My guess is that either
__xor__y(or both) areconst. You can’t call a non-const member function on__xif it’sconst, also you can’t pass__yas therightparameter if__yisconstandrightis not.