I think that it comes down to deciding whether the behavior you are talking about is something that belongs to the hierarchy that the Base knows and implements the child.
If you come with a callback solution, then the callback method (depending on the signature) should not be implemented in the Base child. This may be appropriate if, for example, you wanted to say “this event happened” with a “listener of events”, which may be in a derived class or may be in a completely unrelated class, which seems to be interested in the event.
If you go with solving a virtual function, then you are more closely related to implementing the Derived and Base classes.
An interesting read that might somehow answer your question: C ++ callbacks that talk about using functors. There is also a Wikipedia example that uses a template callback to sort. You will notice that the implementation for the callback (which is a comparison function) does not have to be in the sorting object. If this were implemented using virtual methods, this is not so.
source share