title: Why is an object's destructor not called when an exception is thrown from its constructor?
body: <p>Can anyone explain me why the output of the below snippet is :<br></p>
  
  <blockquote>
  <pre><code>MyClass constructor
  catch block
  </code></pre>
  </blockquote>
  
  <p>Why is the destructor of object <code>m</code> not been called as the scope of it is within try block?<br>
  When it comes to catch block with <code>throw 0;</code> statement, the object <code>m</code> of <code>MyClass</code> is out of scope and its destructor should have been invoked right?</p>
  
  <p>Am i missing some kind of concept hear?</p>
  
  <pre><code>class MyClass {                                                                 
  public:                                                                     
      MyClass() {                                                                 
          std::cout &lt;&lt; "\nMyClass constructor" ;                                  
          throw 0;                                                                
      }                                                                           
      ~MyClass() {                                                                      
          std::cout &lt;&lt; "\nMyClass destructor" &lt;&lt; std::endl;                       
      }                                                                           
  };                                                                              
  
  int main(void)                                                                  
  {                                                                               
      try {                                                                       
          MyClass m;                                                            
      } catch(int e) {                                                            
          std::cout &lt;&lt; "\ncatch block" &lt;&lt; std::endl;                              
      }                                                                           
  
      return 0;                                                                   
  }    
  </code></pre>