Question:Consider the following code:
#include<iostream>
using namespace std;

class A
{
public:
  A()
  {
    cout << "Constructor of An";
  };
  ~A()
  {
    cout << "Destructor of An";
  };
};

class B
{
public:
  B()
  {
    cout << "Constructor of Bn";
  };
  ~B()
  {
    cout << "Destructor of Bn";
  };
};

class C
{
public:
  A objA;
  B objB;
};

int main()
{
  C *pC;
  pC = new C();
  delete pC;
  return 0;
}
What will be the printed output? 

A Constructor of B Constructor of A Destructor of A Destructor of B 

B Constructor of A Constructor of B Destructor of B Destructor of A 

C Constructor of B Constructor of A Destructor of B Destructor of A 

D Constructor of A Constructor of B Destructor of A Destructor of B 

E The sequence of construction and destruction of A and B will be compiler specific 

+ Answer
+ Report
Total Preview: 662

Copyright © 2024. Powered by Intellect Software Ltd