Why doesn't this reinterpret_cast compile?

前端 未结 11 719
暗喜
暗喜 2020-12-04 16:32

I understand that reinterpret_cast is dangerous, I\'m just doing this to test it. I have the following code:

int x = 0;
double y = reinterpret_c         


        
11条回答
  •  广开言路
    2020-12-04 16:43

    Casting an int to a double doesn't require a cast. The compiler will perform the assignment implicitly.

    The reinterpret_cast is used with pointers and references, e.g., casting an int * to a double *.

提交回复
热议问题