|
-
February 5th, 2009, 02:08 PM
#5
Re: Simple class, delete exception
 Originally Posted by streamer
You don't have any problem.
However you should write
if(o1)
{
delete o1;
o1 = NULL;
}
Possibly you are not deleting Cell class properly,
If you have ie defined some variable globally, as
Cell g_MYCELLS[10][10];
destructor is called on the end of program exit if I know well.
You should put that in class somewhere and call the delete accordingly when program is exiting
class Game
{
Cell *pCells;
~Game()
{
if( pCells ) delete pCells
}
}
He's unconditionally setting them in the constructor.
Calling delete on a null pointer is okay.
There's no point in setting their value to NULL in a destructor because they won't be accessible again anyway.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|