title: Call base class constructor after the derived class constructor in C++
body: <p>Consider the following situation:</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  class A {
    public:
      int y;
      A(int &amp;x) {
          x = 2;
          y = 1;
      }
  };
  
  class B : public A {
    public:
      int *p;
      B(int t) : A(*p) {}
  };
  
  int main() {
      B b(2);
      return 0;
  }
  </code></pre>
  
  <p>When the constructor of B is called, <code>p</code> has a junk value. So, when <code>*p</code> is to be passed to <code>A()</code>, it gives me a Segmentation Fault. I would want to initialize <code>p = new int;</code> <em>before</em> calling <code>A(*p)</code> - is this possible?</p>
  
  <p>EDIT: Interestingly, calling <code>B</code>'s constructor without arguments didn't give a segmentation fault. </p>