A pointer is a variable that stores as value a memory address.
The type of a pointer defines the size of the memory area the it points to starting from the memory adress it stores.
Dereferencing replaces the pointer with data stored in the memory area it points to.
It’s possible to have a pointer that points to another pointer or a collection of pointers.
A pointer can also store the memory adress of a function so that it points to that function .
A modern compiler would not allow you to directly manipulate the memory adress that the pointer stores for security reasons except in case of an array.
The name of an array is a pointer, each index of the array is a value that is in a memory address stored in the name of the array plus any number added to that name. The result of that addition depends on the type of the array that defines the size of each index.
A NULL pointer is a painter that stores as value NULL. That means that pointer has an unknown adress stored as value. The adress can become known as soon as the pointer is assigned a new known adress.
In case of void pointer the adress is known but the size of the memory area is unknown. Thus the type of the pointer is unknown. When in that memory area enters data the pointer type is changed from unknown to the type of the data.
Pointers normally can manipulate and point to memory areas residing inside a major memory area known as " Stack" . This area is used to store temporary small size data. It’s used by functions to store the values of their variables and is deleted after the execution of a function.
For more permanent big data a pointer should use a major memory area called the “Heap”. Heap is much larger than the stack. A pointer can use the heap with the new() function and can release the memory area it points to with the delete() function. When a memory area is released a pointer pointing to that area will no longer point to that area and the data in that area will be deleted.
If memory areas are not deleted then Heap will keep growing in size to such extend that even make the system run out of RAM forcing the OS to use the hard disk as virtual memory. Because the hard disk is much slower the application and the entire OS will become much slower. This phenomenon is called “memory leak”.
A smart pointer is a pointer that is smart enough to know that when it’s no longer used to release the memory area it points to and thus it does not permit the creation of memory leaks.