Pointer to deallocated location Is it a Undefined Behavior?
问题 Pointer to deallocated location Is it a Undefined Behavior? http://ideone.com/Qp3uY int *p = new int; *p = 10; delete p; *p = 10; cout << *p << endl; 回答1: There mere existence of a pointer to a deallocated location is not undefined behavior in itself. Attempting to dereference that pointer does produce undefined behavior though. 回答2: Dereferencing a deleted pointer is an undefined operation. Don't do it. 回答3: This is undefined behavior: If the argument given to a deallocation function in the