Pure virtual functions allow the compiler to verify that client code implements the handler. Virtual dispatch is activated immediately after the creation of the object, and someone who looks at the derived class can accurately determine its processing. The data needed for processing can be conveniently and clearly grouped into a derived class. Factories can still select a specific derived class to instantiate.
Function pointers are a state of runtime, so you need to take care to initialize them in a timely manner, for additional checks of runtime during their installation and error handling, as well as the reason why the set is valid during program execution. In this case, there is great freedom to change them during the life of the object.
A third alternative is a Curiously Recurring Template Pattern to block compile-time behavior. This potentially allows you to embed callbacks, eliminate dead code, and other optimizations.
source share