Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Compiler Error C3840

 

declaration of 'method' not allowed; use destructors to implement finalization

Declare a destructor instead of a Finalize method in a managed class.

C3840 is only reachable using /clr:oldSyntax.

The following sample generates C3840:

// C3840.cpp
// compile with: /clr:oldSyntax
#using <mscorlib.dll>
__gc class X
{
protected:

   void Finalize()
   {   // C3840, "declaration of 'X::Finalize' not allowed...
   }

   // declare a destructor instead
   // ~X()
   // {
   // }
};

int main()
{
}
Show: