All objects created with this "self destructive" behaviour are added to a manager. So you can say that you give all the resposibility to the manager when its created. It is the base object of my gui that uses this destroy method in order to remove ALL the children that is attached to it. So codewise it looks something like this:
gui::Window* window = new Window;window -> setSize(400, 300);window -> setPosition(100.0, 300.0);...manager.add(window);...// Main loop.while (1) { ...manager.update();}
So say that you hit the close button on the window object and have to do something like this:
while (1) { if (window -> closeButtonIsClicked()) { delete window;}...}
Instead the manager has a list with all the frames and when the close button is clicked it gets a message that it should DESTROY the frame. When it does it just calls the window's destroy method and removes it from the list.