Export (0) Print
Expand All
Expand Minimize
This topic has not yet been rated - Rate this topic

Compiler Warning (level 1) C4461

Error Message

'type' : this class has a finalizer 'finalizer' but no destructor 'dtor'

The presence of a finalizer in a type implies resources to delete. Unless a finalizer is explicitly called from the type's destructor, the common language runtime determines when to run the finalizer, after your object goes out of scope.

If you define a destructor in the type and explicitly call the finalizer from the destructor, you can deterministically run your finalizer.

For more information, see Destructors and Finalizers in Visual C++.

Example

The following sample generates C4461.

// C4461.cpp
// compile with: /W1 /clr /c
ref class A {
protected:
   !A() {}   // C4461
};

// OK
ref struct B {
   ~B() {
      B::!B();
   }

   !B() {}
};
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.