malloc returns a void * pointer, which you can point to any desired pointer using C-style, but C ++ introduced 4 new translation operators to overcome one drawback associated with C-style casts, and that they cannot be easily detected with using an IDE or any other tools like grep.
Link your example
int *a = (int *)malloc(sizeof (int)); int *b = static_cast<int *>(malloc(sizeof (int))); int *c = reinterpret_cast<int *>(malloc(sizeof (int)));
Here you can easily find all instances of static_cast or reinterpret_cast, but if it were c style cast, then you would have no choice but to just watch or delve into the code and spend sleepless nights. Believe me, error casting is very difficult, and they undermined the strong typing guarantee offered by the C and C ++ languages. But these are some genuine cases when such a cast is required.
Consequently, C ++ allows C-style, but it insulates the reinterpret_cast statement, which does nothing but the operation with the effect of style C.
http://www.stroustrup.com/bs_faq2.html#void-ptr
source share