Top
/
C++
/
Memory
/
Dangling pointers
/
Answer-dangling-4
Answer to Question dangling-4
Variables
p
and
q
point to the same place. when statement
delete p;
is performed, both
p
and
q
become dangling pointers. Statement
printf
("*q = %i\n", *q);
uses dangling pointer
q
. Statement
delete q;
deletes the memory pointed to by
q
a second time. That can ruin the heap manager.