J
Joseph Turian
I have a global method "update_var(double v);", which updates the value
of global variable 'var'.
I have a class Foo, which would like to know when 'var' is updated.
Let's say I make an ABC:
class Notify {
virtual void notify_that_var_has_updated() = 0;
};
and then I use MI to make Foo inherit from Notify.
Finally, I make a global method:
notify_object(Notify* n);
that will keep track of all Notify objects that want to be told when
update_var is called.
Can I make it that constructing Notify will automatically call
'notify_object', and destructing Notify will automatically call
'denotify_object'? This will prevent dangling pointers. If so, how do I
make sure that any deriving class (e.g. Foo) will also call Notify's
constructors and destructors?
of global variable 'var'.
I have a class Foo, which would like to know when 'var' is updated.
Let's say I make an ABC:
class Notify {
virtual void notify_that_var_has_updated() = 0;
};
and then I use MI to make Foo inherit from Notify.
Finally, I make a global method:
notify_object(Notify* n);
that will keep track of all Notify objects that want to be told when
update_var is called.
Can I make it that constructing Notify will automatically call
'notify_object', and destructing Notify will automatically call
'denotify_object'? This will prevent dangling pointers. If so, how do I
make sure that any deriving class (e.g. Foo) will also call Notify's
constructors and destructors?