Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Compiler Error C2675
Collapse the table of content
Expand the table of content

Compiler Error C2675

unary 'operator' : 'type' does not define this operator or a conversion to a type acceptable to the predefined operator

C2675 can also occur when using a unary operator, and the type does not define the operator or a conversion to a type acceptable to the predefined operator. To use the operator, you must overload it for the specified type or define a conversion to a type for which the operator is defined.

The following sample generates C2675.

// C2675.cpp
struct C { 
   C(){}
} c;

struct D { 
   D(){}
   void operator-(){}
} d;

int main() {
   -c;   // C2675
   -d;   // OK
}
Show:
© 2015 Microsoft