Destructor call
<pre><code>#include &lt;iostream&gt;

using namespace std;

class A{
    int b;
public:
    A(){
        cout&lt;&lt;"Constructor for class A called\n";
        b = 6;
    }
    ~A(){
        cout&lt;"Destructor called for class A\n";
    }
};

class B{
    A a;
public:
    B(){
        cout&lt;&lt;"Constructor for class B called\n";
    }
    ~B(){
        cout&lt;&lt;"Destructor called for class B\n";
    }
};


int main(void){
    B obj1;
    return 0;
}
</code></pre>

<p>When the above code is executed the <strong>constructors</strong> for both A and B are called as expected but when B's object i.e. obj1 goes out of scope only B's destructor is called. Why A's <strong>destructor</strong> is not called even though A's obj is one of the members of B ?</p>
