Compiler Error C2593

'operator identifier' is ambiguous

More than one possible operator was defined for the specified overloaded operator.

An explicit cast of one or more of the actual parameters can resolve the ambiguity.

The following is an example of this error:

struct A {};
struct B : A {};
struct X {};
struct D : B, X {};
void operator+( X, X );
void operator+( A, B );
D d;
void main()
{
   d +  d;         // error, D has an A, B, and X 
   (X)d + (X)d;    // OK, uses operator+( X, X )
}

This error can also be caused by serializing a floating-point variable using a CArchive object. The error identifies the operator << as being ambiguous. The only primitive C++ types that CArchive can serialize are the fixed-size types BYTE, WORD, DWORD, and LONG. All integer types can be cast to one of these types for serialization. Floating-point types must be handled differently. They can be archived using CArchive's member function CArchive::Write(). The following example shows how to archive a floating-point variable 'f' to an archive 'ar':

ar.Write(&f, sizeof( float ));