您的位置:首页 > 编程语言 > C语言/C++

C++ self-learning notes(6)

2017-06-22 00:00 459 查看
摘要: Type conversion: static_cast and reinterpret_cast

static_cast and reinterpret_cast are conversion types :

static_cast can perform conversions betwenn pointers and related classes. The command goes as: static_cast<new_type>(expression) . An example is shown below:



result:



reinterpret_cast can convert between completely unrelated pointer types. See the example below:



result:



Check more information about type conversion from the link below.

Useful links:
http://blog.csdn.net/jofranks/article/details/7828331 http://www.cnblogs.com/ider/archive/2011/07/31/cpp_cast_operator_part4.html http://www.cnblogs.com/ider/archive/2011/07/30/cpp_cast_operator_part3.html http://blog.csdn.net/zhuichao001/article/details/7924148 http://blog.csdn.net/querw/article/details/7387594 http://blog.csdn.net/jofranks/article/details/7828339 http://www.cplusplus.com/doc/tutorial/typecasting/
to be continued...
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息