Problems with destructor
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
------------------------
You should never have to directly call a destructor. Destructors are automotically called when your variable goes out of scope.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement