Function
foo is called in the constructor of class a , and at that time the object b was not yet completely constructed, so the implementation of foo not available.
Quote from "Effective C ++":
Do not call virtual functions during construction or demolition, because such calls will never go to a more derived class than the currently executing constructor or destructor
source share