reinterpret_cast本质

来源:互联网 发布:阈值分割算法 编辑:程序博客网 时间:2024/06/09 06:32

reinterpret_cast本质

reinterpret_cast 可以将一个类型所包含二进制内容,重新解释为另一种类型。

#include  < iostream >  using   namespace  std;void  main() {      int  i  =   875770417 ;     cout << i << "   " ;     char *  p  =  reinterpret_cast < char *> ( & i);     for ( int  j = 0 ; j < 4 ; j ++ )        cout << p[j];    cout << endl;     float  f  =   0.00000016688933 ;    cout  << f << "   " ;    p  =  reinterpret_cast < char *> ( & f);     for (int j = 0 ; j < 4 ; j ++ )        cout << p[j];    cout << endl;}

变量与数据类型

将类型进行转换

0 0
原创粉丝点击