I'm trying to create some kind of callback for a class template. The code is like this:
template <typename t>
class Foo {
void add(T *t) {
prinf('do some template stuff');
on_added(t);
}
void on_added(T *t) { }
}
struct aaa {}
class Bar : Foo<aaa> {
void on_added(aaa *object) {
printf("on added called on Bar");
}
}
the on_added function on Bar never gets called. What would be the best way to add a callback that a template subclass could optionally override? Thanks