Export (0) Print
Expand All
Expand Minimize

Compiler Error C2831

Error Message

'operator operator' cannot have default parameters

Only three operators can have default parameters:

  • new

  • Assignment =

  • Left parenthesis (

The following sample generates C2831:

// C2831.cpp
// compile with: /c
#define BINOP <=
class A {
public:
   int i;
   int operator BINOP(int x = 1) {   // C2831
   // try the following line instead
   // int operator BINOP(int x) {
      return i+x;
   }
};

Community Additions

ADD
Show:
© 2014 Microsoft