1. Dangling Pointer
Dangling pointers arise when an object is deleted or deallocated, without modifying the value of the pointer, so that the pointer still points to the memory location of the deallocated memory
As the system may reallocate the previously freed memory to another process, if the original program then dereferences the (now) dangling pointer, unpredictable behavior may result, as the memory may now contain completely different data.
2. Null Pointer
A null pointer is a regular pointer of any pointer type which has a special value that indicates that it is not pointing to any valid reference or memory address. This value is the result of type-casting the integer value zero to any pointer type.int * p;
p = 0; // p has a null pointer value
3. Wild Pointer
Wild pointers arise when a pointer is used prior to initialization to some known state, which is possible in some programming languages. They show the same erratic behaviour as dangling pointers, though they are less likely to stay undetected.
The wild pointer generates garbage memory location and pendent refernce.
4. Void Pointer
- Pointer declared but not initialized
- Pointer alteration
- Accessing destroyed data
When a variable is declared as being a pointer to type void it is known as a generic pointer.
Since you cannot have a variable of type void, the pointer will not point to any data and therefore cannot be dereferenced.
It is still a pointer though, to use it you just have to typecast it to another kind of pointer first. Hence the term Generic pointer.
This is very useful when you want a pointer to point to data of different types at different times.
void * variable name;