First of all it is explicit in specification of those 2 languages and it is enough for compilers to conform to that.
But there are good reasons why C allows implicit conversion from pointer to any to void * and back while C++ disallows it. As C as no inheritance support, all kind of polymorphism requires the use of void *
pointers. So conversion to and from void *
is assumed to be a common use case. Also as you have no static, dynamic or const cast in C, if you want to keep constness of a pointer, you would have to repeat it on each void *
conversion.
But C++ does have inheritance, static and dynamic cast. So conversion from pointer to any to void *
and back has less common use cases and for that reason must be explicit. And last but not least, the usage of new
hides the call to malloc and directly gives a pointer to the proper type avoiding the cast form void *
each time you create a dynamic object.