I have a priority_queue defined in my Items class as a composition object.
priority_queue <Bid> bidQueue;
Bid is a separate class that deals with the input and output of the bids. I've tried identifying the overloaded < operator as a friend function of the item class and defined it in the item.cpp as:
Here I get "Error: class Bid has no member operator <" and the bid variables are inaccesible. I do have it declared in the bid.h file so I don't know why it's appearing. I am at a loss on how to approach solving this. I'd appreciate any help. Thanks.
operator< is declared to have 3 parameters. The implicit this parameter that all member functions have and the two Bid& parameters explicitly listed in the argument list.
The problem, of course, is that operator< is a binary operator. It may only have two parameters. The solution, should you wish it to remain a member function is to change the declaration and definition so that only one parameter is explicit:
1 2 3 4 5 6
class Bid
{
public:
booloperator<(const Bid&) const ;
};