title: Calling the parameterized constructor in class composition
body: <p>Composition is kinda like inheritance but instead of inheriting the super-class, the super-class is a data member of the sub-class.</p>
  
  <p>In such cases, how do you call the parameterized constructor of the super-class whenever an object of the sub-class is created (I know that we can't use the terms sub and super class here but it's just for clarity).</p>
  
  <pre><code>class A {
      int a;
  public:
      A() {
          cout &lt;&lt; "\nDefault constructor of A called.\n";
          a = 0;
      }
      A(int x) {
          cout &lt;&lt; "\nParameterized constructor of A called.\n";
          a = x;
      }
      int getA() {
          return a;
      }
  };
  
  class B {
      A o;
      int b;
  public:
      B() {
          cout &lt;&lt; "\nDefault constructor of B called.\n";
          b = 0;
      }
      B(int x) {
          cout &lt;&lt; "\nParameterized constructor of B called.\n";
          b = x;
      }
      int getB() {
          return b;
      }
  }; 
  
  class C {
      int c;
  public:
      A o;
      C() {
          cout &lt;&lt; "\nDefault constructor of C called.\n";
          c = 0;
      }
      C(int x) {
          cout &lt;&lt; "\nParameterized constructor of C called.\n";
          c = x;
      }
      int getC() {
          return c;
      }
  }; 
  </code></pre>
  
  <p>B and C are two different versions of composition. How to call the parameterized constructor of A in either of them. I mean, please modify the class definitions accordingly.</p>