Follow Us
Contribute
  • Register

Error C3840: declaration of (method) not allowed; use destructors to implement finalization

0 votes

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


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

   void Finalize()
   {   // C3840
   }
};

int main()
{
}

requested 7 years ago by errorbase (170,010 points)

2 Solutions

0 votes

This article is a derivative work based on http://msdn.microsoft.com/en-us/library/e11wacbe.aspx" title="http://msdn.microsoft.com/en-us/library/e11wacbe.aspx" target="_blank">Compiler Error C3840 which is provided by http://msdn.microsoft.com/en-us/library/60k1461a.aspx" title="http://msdn.microsoft.com/en-us/library/60k1461a.aspx" target="_blank">MSDN Community Content - Visual C++.

solved 7 years ago by errorbase (170,010 points)
0 votes

Possible resolution:


// compile with: /clr:oldSyntax
#using <mscorlib.dll>
__gc class X
{
protected:
   ~X()
   {
   }
};

int main()
{
}

solved 7 years ago by errorbase (170,010 points)

Related errors