I’m currently hard at work on an assignment piece, which contains several custom datatypes. I’ve run into a problem where list is complaining that I am trying to remove a custom data type from a list of that same data type.
Error 3 error C2678: binary '==' : no operator found which takes a left-hand operand of type 'customer' (or there is no acceptable conversion) c:\program files (x86)\microsoft visual studio 10.0\vc\include\list 1194 1 Assignment 1 - Video Store MIS
The relevant code is here:
void customerCollection::removeCustomer(customer person)
{
customers.remove(person);
}
and the custom data type does have a == operator defined:
bool customer::operator==(customer &other) const
{
return (l_fullName == other.getName()) &&
(l_contactNumber == other.getNumber()) &&
(l_password == other.getPassword()) &&
(l_username == other.getUsername());
}
Is there any reason that the list type can’t see the overloaded operator?
The customerCollection and customer data types are required parts of the program.
[EDIT] The overloaded operator is defined as public in the header file.
Try changing that to
It is possible the code of the
customerscollection passes a const-qualified customer to the equality operator. At least, it is more idiomatic (and logical).