topical media & game development

talk show tell print


? / basic-program-code-09-Ex9-20-Ex9-20.c

  // Ex9_20.cpp : main project file.
  // Finalizers and destructors
  include <stdafx.h>
  using namespace System;
  ref class MyClass 
    // Constructor
    MyClass(int n) : value(n){}
    // Destructor
      Console::WriteLine("MyClass object({0}) destructor called.", value);
    // Finalizer
      Console::WriteLine("MyClass object({0}) finalizer called.", value);
    int value;
  int main(array<System::String ^> ^args)
    MyClass^ obj1 = gcnew MyClass(1);
    MyClass^ obj2 = gcnew MyClass(2);
    MyClass^ obj3 = gcnew MyClass(3);
    delete obj1;
    Console::WriteLine(L"End Program");
    return 0;

(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.