A wild pointer is a pointer that refers to garbage. There are three ways to get a wild pointer.
In C, the classic example of a dangling reference (3) occurs when a function returns a pointer to a local variable or when someone uses a pointer that has already been passed to free. Both situations can occur in C++, too. Wild pointers are bad news no matter how they are created. Bad enough that we devote this entire chapter to the subject. |