title: Exception in derived class constructor
body: <p>Im having some problems to handle constructor exception in derived classes. When the derived class constructor throws an error, but the parent class has allocated some objects. Will the parent class destructor be called?</p>
  
  <p>Example:</p>
  
  <pre><code>class A
  {
    A() { /* Allocate some stuff */ };
  
    virtual ~A() { /* Deallocate stuff */ };
  };
  
  class B : public A
  {
    B() 
    { 
      /* Do some allocations */
      ...
  
      /* Something bad happened here */
      if (somethingBadHappened) 
      {
        /* Deallocate B Stuff */
        ...
  
        /* Throws the error */
        throw Error; /* Will A destructor be called? I know B destructor won't */
      };
  
    };
  
    ~B() { /* Deallocate B Stuff */ };
  }
  </code></pre>
  
  <p>And i was wondering if it is a good idea to do the following:</p>
  
  <pre><code>B()
  { 
    /* Do some allocations */
    ...
  
    /* Something bad happened here */
    if (somethingBadHappened) 
    {
      /* Deallocate B Stuff */
      this-&gt;~B();
  
      /* Throws the error */
      throw Error; /* Will A destructor be called? I know B destructor won't */
    };
  };
  </code></pre>
  
  <p>If not, whats is a decent way to do such things?</p>