by hybrid » Fri Feb 24, 2012 5:23 pm
If you delete the pointer ('delete myptr' or 'delete [] myarrptr') the underlying object is destroyed. You should never do this with things like the irrlicht device. You should call grab() on those passed in parameters instead, and call drop() in the destructor. This will prevent an intermediate device destruction, while your objects still think that they hold a valid device.
You should only call delete on things that you either created in your constructors (or inside class members, which are then stored in attribute pointers), or on things for which you explicitly take responsibility. This is sometimes very useful, e.g. Irrlicht's CImage can take over the pixel array from the user. That way, the user can create the pixel array and the class is not requested to copy the whole array. But that special constructor or setter explicitly asks the user to give up the memory array, which also needs to be allocated properly (here with new instead of malloc).