I've run into strange problem with binary operator==.
I have a function which returns:
Type< Colors >* get();, T is of type enum Colors {Red,Black}
and I have an operator== defined as:
bool operator==(Type<Colors>* left, Colors right)
{
//...
}
Now, in code I have line:
if (get() == Red)
{
//
}
but here I'm getting error saying that:
error C2679: binary '==' : no operator found which takes a right-hand operand of type 'Colors' (or there is no acceptable conversion)
1> could be 'built-in C++ operator==(Node<Key_T,Value_T> *, Node<Key_T,Value_T> *)'
1> with
1> [
1> Key_T=int,
1> Value_T=int
1> ]
or 'bool operator ==(const Type<T> *,const Colors)'
1> with
1> [
1> T=Colors
1> ]
1> while trying to match the argument list '(Node<Key_T,Value_T> *, Colors)'
1> with
1> [
1> Key_T=int,
1> Value_T=int
1> ]
Obviously the second match is what I've intended to use and it's perfect match yet it doesn't want to ;) compile. What am I doing wrong?
get()function doesn't returnconst Type<Colors>*but ratherNode<Key_T,Value_T>*. Are you callingget()on the appropriate object?costness? That's the only thing I see.get()returnsNode<int,int>!get()function. From the error message it seems the return type ofget()function has some problems or may be yourclass Colorsdoesn't have a properoperator==, but this is just a guess.