A dangling pointer refers to a pointer that points at a no longer valid object. This need not be new/delete or malloc/free based: in fact, non-pointers can dangle. Any reference to another object or resource, where the refereence is no longer valid, but the reference 'does not know that', can be said to "dangle".
If you dereference a dangling pointer, undefined behaviour (sometimes nothing, sometimes a segfault, sometimes your hard drive is formatted, sometimes your code time travels (yes I am serious)) occurs.
So don't dereference dangling pointers.
After the delete
, both pointers are dangling.
Generally, it can help to reason about a program if your code enforces the requirement variables are in known states that you can determine from their type and/or name. One example might be "do not have dangling pointers, set them to null immediately after the delete": then, if you always initialize pointers to null when created, every pointer is either valid or points to null.
Doing this with persistant data is a great idea; doing so with local variables in tiny functions often adds more noise than it helps.
Another approach is to prefer to use smart pointers, but they have their own traps. Reference counting and mark-and-sweep smart pointers turn dangling pointers into resource leaks! And unique ptr has no "observer" pointer type that is safe.
A local pointer after the end of its scope ceases to exist. It cannot be a dangling pointer, as it is not a pointer.