title: delete (this) pointer in destructor
body: <p>I wrote the program just to check what happens if we delete this pointer in the destructor of the classs. Here is my code</p>
  <pre><code> class xxx{
      public: xxx(){cout&lt;&lt;&quot;constructor called&quot;&lt;&lt;endl;}
              ~xxx(){cout&lt;&lt;&quot;destructor called&quot;&lt;&lt;endl;delete(this);}  //deleting the 'this' pointer
   };
   int main(int argc, char *argv[])
   {
      xxx *x1=new xxx();
      delete x1;
      return 0;
   }
  </code></pre>
  <p>When I run this program it results in indefinite loop printing &quot;desctructor called&quot;.</p>
  <p>What is the relation between <code>delete</code> operator and destructor function? Also what happens when you use <code>delete this</code> in the destructor?</p>