c++ 四种挟制类型转换
c++ 四种强制类型转换
--------------------Configuration: type_casting - Win32 Debug--------------------
Compiling...
type_casting.cpp
E:\Microsoft Visual Studio\MyProjects\myWorkplace_1\type_casting\type_casting.cpp(8) : error C2059: syntax error : '('
E:\Microsoft Visual Studio\MyProjects\myWorkplace_1\type_casting\type_casting.cpp(11) : error C2059: syntax error : '('
E:\Microsoft Visual Studio\MyProjects\myWorkplace_1\type_casting\type_casting.cpp(15) : error C2059: syntax error : '('
E:\Microsoft Visual Studio\MyProjects\myWorkplace_1\type_casting\type_casting.cpp(19) : error C2059: syntax error : '('
这是老是给的参考资料,我感觉这里面好像也有有错....


------解决方案--------------------
http://bbs.****.net/topics/390483380
------解决方案--------------------
明显你代码当中的(有问题,不要用中文(
------解决方案--------------------
sorry 好像不是这个问题
------解决方案--------------------
int b=const_cast<int>(a);
# include <iostream>
using namespace std;
int main()
{
const int a=0;
int b=const_cast(a); //消除对象的常量性 意思懂 但是编译不通过!!!
double d=1.5;
int dd=dynamic_cast(d);//安全的向下转型 哪里可以体现向下?? 不解。。。编译不通过!!!
char ch='a';
int cch=reinterpret_cast(ch);//底层的强制转型 这里底层是啥子意思??
float f=2.5;
int ff=static_cast(f);//基本数据类型之间的转换 这个懂起了 但是编译不通过!!!
return 0;
}
--------------------Configuration: type_casting - Win32 Debug--------------------
Compiling...
type_casting.cpp
E:\Microsoft Visual Studio\MyProjects\myWorkplace_1\type_casting\type_casting.cpp(8) : error C2059: syntax error : '('
E:\Microsoft Visual Studio\MyProjects\myWorkplace_1\type_casting\type_casting.cpp(11) : error C2059: syntax error : '('
E:\Microsoft Visual Studio\MyProjects\myWorkplace_1\type_casting\type_casting.cpp(15) : error C2059: syntax error : '('
E:\Microsoft Visual Studio\MyProjects\myWorkplace_1\type_casting\type_casting.cpp(19) : error C2059: syntax error : '('
这是老是给的参考资料,我感觉这里面好像也有有错....
C++
类型转换
------解决方案--------------------
http://bbs.****.net/topics/390483380
------解决方案--------------------
明显你代码当中的(有问题,不要用中文(
------解决方案--------------------
sorry 好像不是这个问题
------解决方案--------------------
int b=const_cast<int>(a);