derived::print does not override any member function in base . It is declared as having a single parameter of type double , but two virtual member functions named print in base declared as having one and two parameters of type int .
When you use b->print(d) , only the member functions in base are taken into account during overload resolution, so only void base::print(int) and void base::print(int, int) are taken into account. void derived::print(double) cannot be found because the compiler does not know that b points to the derived object.
If derived were to override one of the two print functions declared as virtual member functions in base , then that override would be called at run time.
(In some respects, the note derived::print hides two member functions of base::print , so if you try to use one of the functions of the print base class, for example, derived().print(1, 1) , it will fail. You will need to use a service declaration to make these member functions available during the name lookup.)
source share