Export (0) Print
Expand All
Expand Minimize

Compiler Error C2171

'operator' : illegal on operands of type 'type'

A unary operator is used with an invalid operand type.

The following sample generates C2171.

// C2171.cpp
int main() {
   double d, d1;
   d = ~d1;   // C2171

   // OK
   int d2 = 0, d3 = 0;
   d2 = ~d3;
}

The following sample generates C2171.

// C2171_b.cpp
// compile with: /c
class A {
public:
   A() { STF( &A::D ); }

   void D() {}
   void DTF() {
      (*TF)();   // C2171
      (this->*TF)();   // OK
   }

   void STF(void (A::*fnc)()) {
      TF = fnc;
   }

private:
   void (A::*TF)();
};

Community Additions

ADD
Show:
© 2014 Microsoft