title: Deleting an object in C++
body: <p>Here is a sample code that I have:</p>
  
  <pre><code>void test()
  {
     Object1 *obj = new Object1();
     .
     .
     .
     delete obj;
  }
  </code></pre>
  
  <p>I run it in Visual Studio, and it crashes at the line with 'delete obj;'.
  Isn't this the normal way to free the memory associated with an object?
  I realized that it automatically invokes the destructor... is this normal?</p>
  
  <hr>
  
  <p>Here is a code snippet:</p>
  
  <pre><code>    if(node-&gt;isleaf())
      {
          vector&lt;string&gt; vec = node-&gt;L;
          vec.push_back(node-&gt;code);
          sort(vec.begin(), vec.end());
  
          Mesh* msh = loadLeaves(vec, node-&gt;code);
  
          Simplification smp(msh);
  
          smp.simplifyErrorBased(errorThreshold);
  
          int meshFaceCount = msh-&gt;faces.size();
  
          saveLeaves(vec, msh);
  
          delete msh;
      }
  </code></pre>
  
  <p><code>loadleaves()</code> is a function that reads a mesh from disk and creates a <code>Mesh</code> object and returns it.(think of <code>vec</code> and <code>node-&gt;code</code> are just information about the file to be opened)</p>
  
  <p>Should I remove the <code>delete msh;</code> line?</p>