Hello! I'm a bit confused about basic C++ develpment.
I have a class called CBox and one of its attributes is CExampleClass* pClass; I
attribute NULL to this pointer in CBox constructor.
Somewhen in running time, I call a method (called CBox::setPointer() for example)
and in its scope I write the line below:
pClass = new CExampleClass();
I don't delete it in the end of this routine (delete pClass) but keep on using
this pointer in the other methods that are called soon afterwards.
I write the line in the CBox class destructor:
if (pClass != NULL) delete pClass;
I thought this would prevent from memory leaks but it didn't. What is the problem?