title: Implementation of finally in C++
body: <p>Is this a good way to implement a Finally-like behavior in standard C++?
  (Without special pointers)</p>
  
  <pre><code>class Exception : public Exception
      { public: virtual bool isException() { return true; } };
  
  class NoException : public Exception
      { public: bool isException() { return false; } };
  
  
  Object *myObject = 0;
  
  try
  {
    // OBJECT CREATION AND PROCESSING
    try
    {
      myObject = new Object();
  
      // Do something with myObject.
    }
  
    // EXCEPTION HANDLING
    catch (Exception &amp;e)
    {
      // When there is an excepion, handle or throw,
      // else NoException will be thrown.
    }
  
    throw NoException();
  }
  
  // CLEAN UP
  catch (Exception &amp;e)
  {
    delete myObject;
  
    if (e.isException()) throw e;
  }
  </code></pre>
  
  <ol>
  <li>No exception thrown by object -> NoException -> Object cleaned up</li>
  <li>Exception thrown by object -> Handled -> NoException -> Object cleaned up</li>
  <li>Exception thrown by object -> Thrown -> Exception -> Object cleaned up -> Thrown</li>
  </ol>