Destructor getting called on assigning the deleted pointer to a new object
<pre><code>    #include &lt;iostream&gt;
    #include &lt;cstdlib&gt;
    #include &lt;string.h&gt;

    using namespace std;

    class A {
            public:
            A () {cout&lt;&lt;" A\n";}
            virtual ~A () {cout&lt;&lt;" ~A\n";}
            };

    class B : public A {
            public:
            B () :A() {cout&lt;&lt;" B\n";}
            virtual ~B() {cout&lt;&lt;" ~B\n";}
            };

    int main (int, char *[]) {
            A *ap = new B;
            delete ap;
            A b = *ap;
            return 0;
            }
</code></pre>

<p>Output is :</p>

<pre><code>  A

  B

 ~B

 ~A
</code></pre>

<p>Why the last destructor of A is getting called for A b = *ap
Why not the constructor for A is getting called here  ?</p>

<p>Thanks !!!</p>
