::
::
::
::
::
- reinterpret_cast <new_type> (expression) :该转换不考虑expression的类型相当于地址空间的从新分配,参见C++标准转换运算符reinterpret_cast。
typedef int (*FunctionPointer)(int);
int value = 21;
FunctionPointer funcP;
funcP = reinterpret_cast<FunctionPointer> (&value);
funcP(value);
这个过程编译器都成功的编译通过,不过一旦运行我们就会得到"EXC_BAD_ACCESS"的运行错误,因为我们通过funcP所指的地址找到的并不是函数入口。
- static_cast <new_type> (expression) :该转换会进行类型检查,只有upcasting以及void*和其他类型间的转换才能成功
- dynamic_cast <new_type> (expression) :检查类型间的继承关系C++标准转换运算符dynamic_cast
posted on
2012-02-14 19:06
Junhv.W
阅读(
119)
评论()
编辑
收藏
举报