#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 intitialization 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; }
// Interchange 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& a) { 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; }
//          B(const B& b) 
// Comment out the following line:
//          : A(b)
//              { cout << "Copy Constructing from B" << endl; }
          ~B(){ cout << "Destructing from B" << endl; }
};

main()
{
   B b1;
   B b2(b1);

/*
  A a1;
  A a2(a1);
*/
}

