I have a rather simple question, and I' ve been looking for the answer for awhile, but did not find any.
So I would like to know, what is the proper way of deleting a pointer.
For example I have a class with some kind of array, which I want to extend later. But what if, for some reason, I won't have to. Like, I am opening a file, but it is not there, so I don't need to allocate any memory. Eveything is OK, then destructor starts working and then the whole program crashes. Altough It works fine if it had some amount of memory allocated before.
So would you please show me the proper way of deleting pointers?
Thank you very much.
myClass::~myClass()
{
if( my_array != 0 )
{
delete []my_array;
}
}
I didn't want to off, so if it is just kill it. 'SOORY'