Say that you have a event handler interface like
and implement it something likeCode:class KeyboardEventHandler { public: virtual bool KeyDown(const KeyboardEvent&) = 0; virtual bool KeyUp(const KeyboardEvent&) = 0; };
With possible later usage looking likeCode:class ApplicationState : private KeyboardEventHandler { private: virtual bool KeyDown(const KeyboardEvent&) { return true; } virtual bool KeyUp(const KeyboardEvent&) { return true; } };
Is the private inheritance kosher in this case? I want the ApplicationState to behave as-a KB event handler to recieve input, but I don't want the whole world to see the event handler functions - only the Keyboard class that will be sending the events. This compiles and runs fine with MSVC9, I just want to double check that it isn't something being enabled by an MSVC extension.Code:Keyboard kb; ApplicationState appState; kb.RegisterEventHandler(&appState);




Reply With Quote