Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

garbage collection and dangling reference

int x= 1000;   //creates a new 
memory block
int* p = x;   // *p is the pointer to address block 1000(mem location) 
int *p = 20;
printf("%d",*p); //This pointer prints 20 
delete p; 
printf("%d",*p); // This would throw an error, because now p is 
                 // inaccessible or dangling. *p is a dangling pointer.
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #garbage #collection #dangling #reference
ADD COMMENT
Topic
Name
9+2 =