C
Christopher
I have a class FrameListener, that contains a method which loops
continually, if this method returns false then the application exits.
I have a class KeyListener, that gets input from the user.
Both these classes are 3rd party and beyond my control. I can however derive
from these as long as the base functionality is intact. I did indeed derive
from these and make my own custom functionality on top.
My question is how can I design things so that the KeyListener can let the
FrameListener know when a user hits escape so that the FrameListener can
exit the application?
I am not sure whether to
(A) make a class derived from both FrameListener and KeyListener holding
some bool like m_continue_loopig
(B) keep them seperate as suggested by the 3rd party and make some
event/event handler design (C++ doesn't directly support this as far as I
know)
(C) have FrameListener contain KeyListener (i guess KeyListener would have
to take a FrameListener reference in its constructor)
(D) ...any suggestions?
I am sure this kind of communication between objects is common. What kind of
things should I ask myself and what designs should I consider?
Thanks.
Christopher
continually, if this method returns false then the application exits.
I have a class KeyListener, that gets input from the user.
Both these classes are 3rd party and beyond my control. I can however derive
from these as long as the base functionality is intact. I did indeed derive
from these and make my own custom functionality on top.
My question is how can I design things so that the KeyListener can let the
FrameListener know when a user hits escape so that the FrameListener can
exit the application?
I am not sure whether to
(A) make a class derived from both FrameListener and KeyListener holding
some bool like m_continue_loopig
(B) keep them seperate as suggested by the 3rd party and make some
event/event handler design (C++ doesn't directly support this as far as I
know)
(C) have FrameListener contain KeyListener (i guess KeyListener would have
to take a FrameListener reference in its constructor)
(D) ...any suggestions?
I am sure this kind of communication between objects is common. What kind of
things should I ask myself and what designs should I consider?
Thanks.
Christopher