Hello
I'm currently writing some library code and I want to allow certain events
to be handled by whatever app is using this library. E.g. responding to
error messages by printing them/logging them to a file/whatever.
I can see two good options:
1) Hold a function ptr which can be set by the application to point to one
of its (presumably static?) methods.
2) Hold a ptr to an object of some sort of 'handler' class, so the app can
derive its own type from this and override the virtual methods. This could
be an abstract base class, or possibly could have default empty
implementations of the methods.
Anyone have any thoughts about which of these various possibilities would be
preferable, or even come up with something better?
thanks!
G.A.