#include <iostream>
using namespace std;

// Add comments gradually to the copy constructor definitions
// of the following classes starting from the derived class
// to see copy construction initialization under inheritance
// and composition

class A1 {
public:
   A1()
   {  cout << "Constructing from A1" << endl; }

   A1(const A1& a1)
   {  cout << "Copy Constructing from A1" << endl; }

   ~A1()
   {  cout << "Destructing from A1" << endl; }
};

class A2 {
public:
   A2()
   {  cout << "Constructing from A2" << endl; }

   A2(const A2& a2)
   {  cout << "Copy Constructing from A2" << endl; }


   ~A2()
   {  cout << "Destructing from A2" << endl; }
};

class A {
   A1 a1;
   A2 a2;
public:
   A()
   {  cout << "Constructing from A" << endl; }

// A(const A& a) : a1(a.a1), a2(a.a2)
// {  cout << "Copy Constructing from A" << endl; }
// Swap with the following copy constructor

   A(const A& a)
   {  cout << "Copy Constructing from A" << endl; }

   ~A()
   {  cout << "Destructing from A" << endl; }
};

class B1 {
public:
   B1()
   {  cout << "Constructing from B1" << endl; }

   B1(const B1&  b1)
   {  cout << "Copy Constructing from B1" << endl; }

   ~B1()
   {  cout << "Destructing from B1" << endl; }
};

class B : public A {
   B1 b1;
public:
   B()
   {  cout << "Constructing from B" << endl; }

// Uncomment the following lines:
// B(const B& b)
//    : A(b)
// {  cout << "Copy Constructing from B" << endl; }

   ~B()
   {  cout << "Destructing from B" << endl; }
};

int main()
{

   B b1; 
/*
   B b2(b1);
*/
/*
   A a1; A a2(a1);
*/
   return 0;
}
