I\'m learning C++ from scratch, and as such I don\'t have an expert understanding of C. In C++, you can\'t cast a void pointer to whatever, and I understand the reasons behi
What are the possible reasons for [casting a
void *
pointer in C]? Isn't this a giant hole in type safety?
It's the only possible way to support polymorphism, aka generic programming. There's no other way to make, e.g., a generic hash table. Polymorphism in C is wildly unsafe, but it's the only polymorphism there is.
Be glad that C++ has parametric polymorphism (one of the many functions of templates).