I know that the destructors of objects will always take care of the simple, "normal" pointers, but I know that when pointers within the classes are used to create dynamic arrays and stuff, code must be written inside the destructors to make sure these are handled properly. For example, a destructor of class Comp, should Comp contain a dynamic array made through a pointer called mem, might look like this:
It is there that I have a little bit of a blind spot. I can't quite remember how to write those destructors correctly, and I'm having difficulty simply being able to look it up. I know that it looks something like that, but I don't remember the details. Can anybody fill me in?Code:Comp::~Comp() { if (mem != NULL) { delete [] mem; } }
Thanks.