Predict the output

Predict the output of the following code snippet.

using namespace std;
class A
{
 public:
 ~A() 
 {
 cout << "Destructor of class A\n"; 
 }
};
class B:public A
{
 public:
 ~B() 
 { 
 cout<< "Destructor of class B\n"; 
 }
}; 
int main()
{
 A* a = new B; 
 delete a;
}
Options
  1. Destructor of class A
  2. Destructor of class B
  3. Destructor of class ,Destructor of class B
  4. Destructor of class B,Destructor of class A

Related Posts