title: What will happen if you delete this in C++
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1258055/is-it-ok-to-use-delete-this-to-delete-the-current-object">Is it OK to use &ldquo;delete this&rdquo; to delete the current object?</a>  </p>
  </blockquote>
  
  
  
  <p>I just saw some code where they have done <code>delete this;</code> in a class function, I know that this is not a good design but is it defined what will happen, lets say that the class always is a pointer from somewhere. Will it always be deleted in the correct way?</p>
  
  <pre><code>class A
  {
   public:
      void abort() { delete this; }
  };
  
  class B
  {
      void func() { A* a = new A; a-&gt;abort(); }
  };
  </code></pre>