title: Why calling pure virtual function imlemented in child inside constructor doesn't work?
body: <p>I am trying to understand why, and if it is possible to call child method from parent constructor.</p>
  
  <p>First I tried:</p>
  
  <pre><code>#define prn printf(__FUNCTION__);printf("\r\n");
  
  class A
  {
  public:
      A(){init();}
       ~A(){prn;}
  
       virtual void f(){}
  
       virtual void init()=0;
  };
  
  class B : public A&lt;B&gt;
  {
  public:
      B(){prn;}
      ~B(){prn;}
  
      virtual void init(){prn;}
  };
  </code></pre>
  
  <p>Which crushed with pure virtual call. I can guess its because init() in A() points to init() in A's virtual table. With this line I confirmed it:</p>
  
  <pre><code>virtual void init()=0{prn};
  </code></pre>
  
  <p>So, I tried the following:</p>
  
  <pre><code>template&lt;typename T&gt;
  class A
  {
  public:
      A(){((T*)this)-&gt;init();}
       ~A(){prn;}
  
       virtual void f(){}
  
       virtual void init()=0{prn;}
  };
  
  class B : public A&lt;B&gt;
  {
  public:
      B(){prn;}
      ~B(){prn;}
  
      virtual void init(){prn;}
  };
  </code></pre>
  
  <p>Which also crushed! Now my only guess is that it happens because the virtual table is just being made,  but its just a guess...</p>
  
  <p>Can anyone explain what is going on?</p>
  
  <p>Thanks!</p>