This documentation is archived and is not being maintained.

Compiler Error C3258

Error Message

managed operators must be declared using 'static op_<Name>' form ('operator' form is disallowed)

An operator overload in a managed class was specified incorrectly.

C3258 is only reachable using /clr:oldSyntax.

The following sample generates C3258:

// C3258.cpp
// compile with: /clr:oldSyntax
#using <mscorlib.dll>

__gc class A {
public:
   A *operator=(const int _i) { // C3258
   // try the following line instead
   // static bool op_Equality(A & _j, A & _k)
   {
      return (_j.i == _k.i);
   }

   int i;
};

int main() {
        A *a = new A;
        A *b = new A;
        a->i  = 11;
        b->i = 11;
        System::Console::WriteLine(*a == *b);
}
Show: