Problems with destructor

Started by
2 comments, last by Leviathan569 22 years, 5 months ago
Hi everybody, I''ve got two classes. One is called TSurface and loads a bitmap into a direct draw surface. The second one, TSprite, is derived from TSurface and has additional properties and methods to move the bitmap across the screen. Now I have the following problem: the destructor from TSprite also has to call the destructor from TSurface to clean up everything. It looks like this: TSprite::~TSprite { blablabla... //clean up TSprite stuff TSurface::~TSurface(); } Instead of calling the TSurface destructor, the TSprite destructor is called again. And again and again and again, resulting in a stack overflow. What am I doïng wrong? ------------------------ leviathan569@hotmail.com ------------------------
------------------------leviathan569@hotmail.com------------------------
Advertisement
You should never have to directly call a destructor. Destructors are automotically called when your variable goes out of scope.
The destructor of the parent class will be called automatically.
Ooooookaaaay. Thanks!
------------------------leviathan569@hotmail.com------------------------

This topic is closed to new replies.

Advertisement