How to use reinterpret_cast in C++?

后端 未结 5 535
无人及你
无人及你 2021-01-01 16:18

I know the reinterpret_cast in C++ can be used in this way:

float a = 0;
int b = *reinterpret_cast(&a);

Bu

5条回答
  •  抹茶落季
    2021-01-01 16:32

    You can't reinterpret_cast in the case you give because reinterpret_cast takes only either a int to convert to a pointer, or the reverse, and follows additional similar rules.

    There is a summary of these rules there: http://en.cppreference.com/w/cpp/language/reinterpret_cast

提交回复
热议问题