#include <iostream>
using namespace std;

class Parent
{
public:
  Parent();
  Parent(const Parent& object);
  Parent& operator=(const Parent& object);

  int p;
};

Parent::Parent()
{ 
  // Write the code for initializing parent
  p = 1;
}

Parent::Parent(const Parent& object)
{ 
  // Write the code for custom copying data fields in Parent 
  p = object.p * 10;
}

Parent& Parent::operator=(const Parent& object)
{
  // Write the code for custom assignment in Parent 
  this->p = object.p * 100;
  return *this;
}

class Child: public Parent
{ 
public:
  Child();
  Child(const Child& object);
  Child& operator=(const Child& object);

  int q;
};

Child::Child()
{ 
  // Write the code for for initializing child
  q = 2;
}

Child::Child(const Child& object): Parent(object)
{ 
  // Note p in Parent is customized by invoking the copy constructor in Parent
  // No need to write p = object.p * 10 because this is done by Parent(object)
  // Write the code for custom copying data fields in Child
  q = object.q * 10;
}

Child& Child::operator=(const Child& object) 
{
  // Write the code for custom copying data fields in Parent
  Parent& temp = Parent::operator=(object);
  this->p = temp.p;
  // Write the code for custom copying data fields in Child
  this->q = object.q * 100;
  return *this;
}

int main()
{
  Child c1;
  Child c2(c1);
  Child c3; // Note that Child c3 = c1 will be the same as Child c3(c1)!!!
  c3 = c1;

  cout << "in c1, p is " << c1.p << endl;  // c1.p is 1
  cout << "in c1, q is " << c1.q << endl;  // c1.q is 1

  cout << "in c2, p is " << c2.p << endl;  // c2.p is 10
  cout << "in c2, q is " << c2.q << endl;  // c2.q is 20

  cout << "in c3, p is " << c3.p << endl;  // c3.p is 100
  cout << "in c3, q is " << c3.q << endl;  // c3.q is 200

  return 0;
}