title: Why is base-class destructor called on derived object when destructor of derived class is non-virtual?
body: <p>Why are all destructors, <code>~D()</code>,<code>~C()</code>,<code>~B()</code>,<code>~A()</code> being called in the example below?</p>
  
  <p>There is only one virtual destructor: that of <code>A</code>.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>#include&lt;iostream&gt;
  using namespace std;
  
  class A
  {
  public:
    virtual ~A()
    {
      cout&lt;&lt;"destruct A\n";
    }
  
  };
  class B:public A
  {
  public:
    ~B()
    {
    cout&lt;&lt;"destruct B\n"; 
    }
  };
  class C:public B
  {
  public:
    ~C()
    {
      cout&lt;&lt;"destruct C\n";
    }
  };
  class D:public C
  {
  public:
     ~D()
     {
       cout&lt;&lt;"destruct D\n"; 
     }
  };
  
  int main()
  {
      A* ptr = new D();
      delete ptr;
      return 0;
  }
  </code></pre>