Void Pointer
Void pointers can point to any data type. Used in Map and Reduce.
You need to cast the type like (int *)pointer
to cast it.
A void* is intentionally designed to be type-agnostic. This allows you to write generic functions (like malloc
) that work with any type of data.
However, since C++ and Python, there are better ways to do this.
In C++, you have Polymorphism, and you can combine that with Smart Pointer.
- Thereās also std::any