12.07.2015 Views

dangling pointer

dangling pointer

dangling pointer

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

The ProblemTraditional “management” of dynamically allocated memory in C++:X* p = new X;// use p, pass it around to other parts of the program// somewhere, sometime, somebody doesdelete p;Common Problems:1) Deletion happens too early. Someone’s still holding a copy of p anddereferences it: <strong>dangling</strong> <strong>pointer</strong>.2) Deletion happens too late, or not at all: memory leak.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!