This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!
Compiler Error C2593
'operator identifier' is ambiguous
More than one possible operator is defined for an overloaded operator.
Possible solution
- Use an explicit cast on one or more actual parameters.
Example
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 )
}
Possible cause
- Serializing a floating-point variable using a CArchive object. The compiler identifies the << operator as ambiguous. The only primitive C++ types that CArchive can serialize are the fixed-size types BYTE, WORD, DWORD, and LONG. All integer types must be cast to one of these types for serialization. Floating-point types must be archived using CArchive's member function CArchive::Write().
The following example shows how to archive a floating-point variable (f
) to archive ar
:
ar.Write(&f, sizeof( float ));