reinterpret_cast
will forcefully convert the void*
to the target data type. It doesn't guarantee any safety and your program might crash as the underlying object could be anything.
For ex, you could typecast an myclass*
to void*
and then use reinterpret_cast
to convert it to yourclass*
which may have a completely different layout.
So its better and recommended to use static_cast