Let's say I make a c++ program in wich I define my own Game class. Obviously, Game class has members like
- IrrlichtDevice* device;
- IVideoDriver* driver;
..and so on.
The device is created in the Game class constructor. A run() method contains the game loop.
The main program is something like this:
Code: Select all
int main(){
Game g;
g.run();
return(0);
}
My answer: I just put device->drop() in the destructor, so I don't need to deallocate pointers like driver and device - because they're been destroyed by device->drop().
If needed, I just have to delete my custom pointers that are not part of Irrlicht Engine.
A mate suggested me a piece of code like this after dropping the device:
Code: Select all
if ( (device) != NULL ) delete (device);
What do you think guys?