Reputation: 41
My program will not compile, and give the error overloaded functions have similar conversions
. What does this mean and how do I fix it?
struct DynamicInt {
bool operator==(const DynamicInt&);
};
int main()
{
DynamicInt a, b;
return a == b; // error at this line
}
Demo.
Upvotes: 0
Views: 295
Reputation: 38863
Just follow the hints in the compiler warnings:
note: mark 'operator==' as const or add a matching 'operator!=' to resolve the ambiguity
and change
bool operator==(const DynamicInt& operand2) const {
^^^^^
and you get it compiled, https://godbolt.org/z/7vdxjEEv4
Upvotes: 3