Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Garbage Collection Example - C++/CLI

By: a guest on Jan 6th, 2012  |  syntax: C++  |  size: 0.43 KB  |  views: 28  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. // GarbageCollection_CLI.h
  2.  
  3. #pragma once
  4.  
  5. using namespace System;
  6.  
  7. namespace GarbageCollection_CLI {
  8.  
  9.         public ref class ObjectHolder
  10.         {
  11.         private:
  12.                 Object^ mSomeObject;
  13.  
  14.         public:
  15.                 ObjectHolder(Object^ someObject)
  16.                 {
  17.                         mSomeObject = someObject;
  18.                 }
  19.  
  20.                 property bool ObjectExists
  21.                 {
  22.                         bool get()
  23.                         {
  24.                                 return mSomeObject != nullptr;
  25.                         }
  26.                 }
  27.  
  28.                 ~ObjectHolder()
  29.                 {
  30.                         mSomeObject = nullptr;
  31.                 }
  32.         };
  33. }