This documentation is archived and is not being maintained.

Compiler Error C2804

Error Message

binary 'operator operator' has too many parameters

The overloaded binary operator is declared with more than one parameter. The first parameter of a binary operator, whose type is the operator's enclosing type, is implied.

Example

The following sample generates C2804.

// C2804.cpp
// compile with: /c
class X {
public:
   X operator+ ( X , X );   // C2804 two parameters
   X operator+ ( X );   // para1 type implicitly X&, para2 type 'X'
};

int main() {
   X x, y;
   x + y;   // equivalent to x.operator+(y)
}

The following sample generates C2804.

// C2804_2.cpp
// compile with: /clr /c
ref struct Y {
   Y^ operator +(Y^ hY, int i);   // C2804
   static Y^ operator +(Y^ hY, int i);   // OK
   Y^ operator +(int i);   // OK
};
Show: