I have read in a lot of books that for every "new" you must use a delete....But in some books I have been currently reading they don't bother deleting their pointer to a class.
I have read it is required at cplusplus.com to delete a pointer to a class but other books make no mention of it only standard type variables.
So is it required or not?
Here is an example if my post seems confusing:
is this ok?
void SomeClass::someMethod()
{
AnotherClass *object = new AnotherClass();
object->doSomething();
}
or do you have to do this?
void SomeClass::someMethod()
{
AnotherClass *object = new AnotherClass();
object->doSomething();
delete object;
}