Yes, I know that. This was a quick and dirty example to illustrate a point.
Don't use print, use cout.
The code that I'm having trouble with is big and complex. But I'll strip out the stuff that isn't necessary. Here goes:
virtual void draw();
virtual void initialize();
class Window : public Control
class DebugWindow : public Window
In particular the trouble shows up when I run the addControl() function:
mChildControls.back()->initialize() only ever gets called once and only runs the initialize() function from the class Control, not Window or DebugWindow.
void Control::addControl(Control *control)
The update function looks like this:
This function tells the Control to draw itself and then to iterate through all of its children and tells them to update themselves which in turn calls their update and so on... Now, this works. The correct draw() function is called.
for(unsigned int i = 0; i < mChildControls.size(); i++)
I may have just answered my own question as to why so now the question has turned into how. But just in case, I'm still asking...
mChildControls is defined as a vector<Control*>. There are probably a few things here and there that don't appear to be defined but just note that I've stripped out all of the irrelevant functions/variables/etc.