...
C and C++ are strongly typed languages, meaning that blocks of memory are given a specific type (i.e., int, float, char, etc.) when allocated or used within a piece of code. Sometimes, it is desirable to write functions that can perform the same operations on different variable types. In C++, this is achievable through class inheritance. However, in C, this is done by telling the compiler not to check the type of the variable; this is done with the void*
declaration. Specifically, void*
is a pointer to untyped memory, and the programmer is free to cast this memory into any other type:
...