I'm using a priority queue consisting of a pair of an object of a class called Nodo
and a value of type float
(I chose it instead of double, thinking it takes up less bytes).
The error I get is in the comparison operator >
that I overloaded because the priority queue that used the values located higher in the queue are the smallest, however, I am a beginner in C ++, and despite to check the code again and again, I have not been able to debug the errors. Codes (declaration and definition, in class Nodo
):
friend bool operator()(const pair<Nodo&,float> nodo1,const pair<Nodo&,float> nodo2);
bool car::operator()(const pair<Nodo& a,float cost1> nodo1,const pair<Nodo& b,float cost2> nodo2){
return (nodo1.second) > (nodo2.second)
}
errors:
error: ‘bool operator()(std::pair<Nodo&, float>, std::pair<Nodo&, float>)’ must be a nonstatic member function
friend bool operator()(const pair<Nodo&,float> nodo1,const pair<Nodo&,float> nodo2);
^
car.cpp:68:56: error: wrong number of template arguments (1, should be 2)
bool car::operator()(const pair<Nodo& a,float cost1> nodo1,const pair<Nodo& b,float cost2> nodo2){
I would also appreciate if you could give me some practical tips on debugging the code. Thanks