title: C++ - Avoiding memory leak with exceptions
body: <p>Let's say you have some code like this:</p>
  
  <pre><code>void myFunction()
  {
      myClass * mine = new myClass();
      // body of function
      delete mine;
  }
  </code></pre>
  
  <p>If an exception is thrown within the body of the function, the <code>delete</code> will never be called and a memory leak will result. What is the best way to alleviate this, other than using any of the managed pointers within <code>&lt;memory&gt;</code>. </p>