I create 2 pointers to the same point. What happen when I use "delete" with the first pointer? Is the content of the second pointer detroyed?
Printable View
I create 2 pointers to the same point. What happen when I use "delete" with the first pointer? Is the content of the second pointer detroyed?
Yes but not the pointer itself (neither the first, nor the second) so after the delete both pointers points to invalid memory space.
Next delete on second pointer should caous an exception. That why people discover smart pointers or auto pointers.
macabre13, no the next delete on second pointer will cause undefined behaviour.