dangling pointer

Hi,
while executing below programme on my Dev-c++ 4.9.9.2 compiler , i was bit amazed as it should have not run properly due to use of deleted object (obj). can anybody let me know instead of crashing , it is getting executed without any memory issue.
~Mohan

I don't see any object being used after it is deleted. There are only two deletions. After the first one the pointer is immediately overwritten, and the second one is practically at the end of the program. Could you provide the line number where a deleted object may be used?

This is legal. Even though you deleted the obj (freed that memory), the pointer is overwritten by the next line obj = obj2.create();. So by calling obj->show(); after that, it would perfectly display "Derived2", since obj points to a new Object of type Derived2.