In my project I have a parent class CWnd which is the base win32 window for classes down the chain. I then create instances of this class with a template declaration so that I can have many different types of windows.
I then add members like so:
void CChildWndClass::OnSize(HWND hWnd, UINT state, int nWidth, int nHeight)
{
// do something
}
The problem is that these members are virtual. In some events (ie: OnDestroy) there is code that I would like to execute in every window class regardless without having to copy paste into each child class because it overrides the parents original code.
How can I have the functions in the children classes append their code to themselves, rather than override?
Subclass into a class with the functionality you desire, and then subclass from that class of your own to obtain similar subclasses.
The method you don’t want to implement, simply don’t, and they continue to be virtual in the subsubclasses.
People also use to make libraries in those situations.