The derived virtual function print
try to call the base version in its function body, but without the scope operator, the call will be resolved at run time as a call to the derived version itself, resulting in an infinite recursion.
To fix this problem, we need to prefix the scope operator to the call like base::print(os);
.