The dynamic binding that you want is a non-static behavior.
Dynamic binding is binding based on the this
pointer, and static
functions by definition don't need or require a this
pointer.
Assuming that you need the function to be static in other situations (it doesn't need to be static in your example) you can wrap the static function in a non-static function.
class ClassA
{
// (the rest of this class is unchanged...)
virtual void dynamic_print()
{
ClassA::print();
}
};
class ClassB : public ClassA
{
// (the rest of this class is unchanged...)
virtual void dynamic_print()
{
ClassB::print();
}
};