I´m trying to accomplish the same which is described in a previous question:
virtual function call from base class
But, my real question is:
What if
The virtual mechanism does not work in the constructors, so if you call even a virtual function from a base class constructor you will always end up calling the functions of the base class only. There are a few reasons why the virtual funcs do not work in the ctors:
Even though it's a virtual function, the base's version will get called since the derived class isn't fully constructed yet. The base class constructor is called before the derived class constructor, so if the derived virtual function were to get called, it would be with an incompletely-initialized instance - a possible (probably) recipe for disaster.
When your base class constructor is called, only the vtable for the base class is setup, so any virtual function calls will apply only to base class methods.
When the derived class constructor is called, calling a virtual function will call the derived class override, if any.
It will Base::g(). See this FAQ for explanation.