12.6 POINTER TO VOID
C++ allows us to declare a pointer-to void. Consider the following declaration:
void * ptr1;
It declares a variable ptr1 of type pointer. It points to void. You may wonder what the use of such pointer declaration is. We have studied some functions, which are of type void. Even if they do not return any value, they do some processing/computing and the effect felt outside the function body through reference parameters. There can be no variables or objects that can be declared as void. Then what is the significance of this declaration?
It may be noted that a pointer can point to an integer or a double or even an object. Such pointers are grammatically different from each other. However, internal representation of a pointer is ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access