Pointer

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.

void* ptr = malloc(sizeof(int));  // Allocates memory for an int
*(int*)ptr = 42;  // Cast void* to int* and assign a value

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.