Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Sailorstick

How to force a particular destructor?

This topic is 5559 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Example:
Form::~Form(){
	Window* ctrl=this->controls;
	Window* temp;
	while(ctrl!=NULL){
		temp = ctrl->next;
		delete ctrl;
		ctrl = temp;
	}
}
Window is an abstract class and has no destructor of it''s own. I have a RoundTree control that is inherited from an abstract class TreeView (again, no destructor) which is inherited from Window. So, RoundTree is a Window which I am able to add to Form->controls. Problem is, when I delete a form, the Form destructor gets called but the line "delete ctrl;" never calls the RoundTree destructor and I get huge memory leaks. How can I force it to be called?

Share this post


Link to post
Share on other sites
Advertisement

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!