Hi all,
If I want to check if memory has already been alocated to a pointer, and if it has I wnat ot delete it, is this how it would work?
theGraph = new MyObject[size()];
if (theGraph != 0){ // or even NULL
delete[] theGraph;
}
This seems intuitive to me, however whether memory has been allocated or not, it still tries to delete. E.g. if the memory address pointed to by the pointer is 0xcdcdcdcd it doesn't take this as NULL even though its not the result of a memory allocation!
Not sure if this makes sense, but if anyone can spot my problem I'd be grateful!
Cheers