//1.静态类型转换 static_cast double pi = 3.1415926; int num = static_cast(pi); //静态类型转换,编译时c++会做类型检查,不会发生警告 int num2 = pi;//发生警告 double 到 int可能丢失数据 //2.重新解释类型 reinterpret_cast char* c = "hello"; int* i = NULL; //i = c; // error "=" 无法从char*转换到int* //i = static_cast (c); // error “static_cast” : 无法从“char * ”转换为“int* ” i = reinterpret_cast (c);//强制类型转换 cout << "c: " << c << " i: " << i << endl;// c: hello 内容; i: 00259B30地址



