When to use reinterpret_cast?

前端 未结 11 1310
我寻月下人不归
我寻月下人不归 2020-11-22 08:41

I am little confused with the applicability of reinterpret_cast vs static_cast. From what I have read the general rules are to use static cast when

11条回答
  •  [愿得一人]
    2020-11-22 09:30

    Read the FAQ! Holding C++ data in C can be risky.

    In C++, a pointer to an object can be converted to void * without any casts. But it's not true the other way round. You'd need a static_cast to get the original pointer back.

提交回复
热议问题