Why do we have reinterpret_cast in C++ when two chained static_cast can do its job?

后端 未结 7 1480
孤城傲影
孤城傲影 2020-12-01 01:58

Say I want to cast A* to char* and vice-versa, we have two choices (I mean, many of us think we\'ve two choices, because both seems to wor

相关标签:
7条回答
  • 2020-12-01 02:36

    Using of C Style casting is not safer. It never checks for different types can be mixed together. C++ casts helps you to make sure the type casts are done as per related objects (based on the cast you use). This is the more recommended way to use casts than using the traditional C Style casts that's always harmful.

    0 讨论(0)
提交回复
热议问题