learncpp
April 13th, 2008, 04:30 AM
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?
|
Click to See Complete Forum and Search --> : a question about "delete" learncpp April 13th, 2008, 04:30 AM 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? S_M_A April 13th, 2008, 04:59 AM Yes but not the pointer itself (neither the first, nor the second) so after the delete both pointers points to invalid memory space. macabre13 April 14th, 2008, 01:09 AM Next delete on second pointer should caous an exception. That why people discover smart pointers or auto pointers. Zaccheus April 14th, 2008, 03:05 AM macabre13, no the next delete on second pointer will cause undefined behaviour. codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |