Dangling Pointer code example
Example: Dangling Pointer
int *p = new int; // request memory
*p = 5; // store value
delete p; // free up the memory
// now p is a dangling pointer
p = new int; // reuse for a new address
int *p = new int; // request memory
*p = 5; // store value
delete p; // free up the memory
// now p is a dangling pointer
p = new int; // reuse for a new address