title: Calling virtual function of derived class from base class constructor?
body: <p>I´m trying to accomplish the same which is described in a previous question:</p>
  
  <p><a href="https://stackoverflow.com/questions/397404/virtual-function-call-from-base-class">virtual function call from base class</a></p>
  
  <p>But, my real question is:</p>
  
  <p>What if f() is the constructor in the Base class? Which g() will be called? I don´t know if I am doing wrong, but in my program it seems to be that is the opposite.</p>
  
  <p>Taking the same variables from the previous question, a code which shows such </p>
  
  <p>behavior would look like this:</p>
  
  <pre><code>Class Base
  
  {   
  
      Base(){g();};
  
      virtual void g(){//Do some Base related code;}
  
  };
  
  
  
  Class Derived : public Base
  
  {   
  
      Derived(){};
  
      virtual void g(){//Do some Derived related code};
  
  };
  
  
  
  int main()
  
  {
  
      Derived newDerived;
  
      return 0;  
  
  }
  </code></pre>
  
  <p><strong>Update:</strong></p>
  
  <p>Thanx to Naveen.</p>
  
  <p>He provided me a page which contains all related information about this topic.</p>
  
  <p>I´ll let you know the link here:</p>
  
  <p><a href="http://www.parashift.com/c++-faq-lite/strange-inheritance.html#faq-23.6" rel="nofollow noreferrer">parashift.com/c++-faq-lite/strange-inheritance.html#faq-23.6</a></p>