바이너리 operator==
에 이상한 문제가 있습니다. T
유형 enum Colors {Red,Black}
의 내가 같은 operator==
정의가, Type<Colors>* get();
을 :바이너리 문제 =
if (get() == Red)
{
//
}
그러나 여기 :
bool operator==(Type<Colors>* left, Colors right)
{
//...
}
이제 코드에서 내가 라인을 가지고
나는 반환하는 기능을 가지고 다음과 같은 오류가 표시됩니다.
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> ]
분명히 두 번째 매치는 내가 사용하려고했던 것이고 완벽한 매칭이지만 아직 원하지 않는다.) 컴파일하라. 내가 도대체 뭘 잘못하고있는 겁니까?
당신이 올린 오류 메시지는'get()'함수가'const Type *'이 아니라'Node *'를 반환한다고 말합니다. 적절한 객체에서'get()'을 호출하고 있습니까? –
Pablo
@Pablo 내가하는 것처럼 내게 보인다. – smallB
get의 정의는 무엇입니까? –