Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The auto_handle destructor.
~auto_handle();
Remarks
The destructor also destructs the owned object.
Example
// msl_auto_handle_dtor.cpp
// compile with: /clr
#include "msclr\auto_handle.h"
using namespace System;
using namespace msclr;
ref class ClassA {
public:
   ClassA() { Console::WriteLine( "ClassA constructor" ); }
   ~ClassA() { Console::WriteLine( "ClassA destructor" ); }
};
int main()
{
   // create a new scope for a:
   {
      auto_handle<ClassA> a = gcnew ClassA;
   }
   // a goes out of scope here, invoking its destructor
   // which in turns destructs the ClassA object.
   Console::WriteLine( "done" );
}
ClassA constructor ClassA destructor done
Requirements
Header file <msclr\auto_handle.h>
Namespace msclr