When you call fun() in the constructor of the base class, the derived class is not yet constructed (in C ++, the constructed parent is created first), therefore, the system does not yet have an Derived instance and, therefore, does not have an entry in the virtual function table for Derived::fun() .
This is why calls to virtual functions in constructors are usually disapproved unless you specifically want to call an implementation of a virtual function that is either part of the object that is currently being created or part of one of its ancestors.
Timo geusch
source share