博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
第11课 - 新型的类型转换
阅读量:3721 次
发布时间:2019-05-22

本文共 965 字,大约阅读时间需要 3 分钟。

 

 

 

 

 

 

 

 

 

 

 

 

#include 
void static_cast_demo(){ int i = 0x12345; char c = 'c'; int* pi = &i; char* pc = &c; c = static_cast
(i); pc = static_cast
(pi); //Error}void const_cast_demo(){ const int& j = 1; int& k = const_cast
(j); const int x = 2; int& y = const_cast
(x); int z = const_cast
(x); //Error k = 5; printf("k = %d\n", k); printf("j = %d\n", j); y = 8; printf("x = %d\n", x); printf("y = %d\n", y); printf("&x = %p\n", &x); printf("&y = %p\n", &y);}void reinterpret_cast_demo(){ int i = 0; char c = 'c'; int* pi = &i; char* pc = &c; pc = reinterpret_cast
(pi); pi = reinterpret_cast
(pc); pi = reinterpret_cast
(i); c = reinterpret_cast
(i); //Error}void dynamic_cast_demo(){ int i = 0; int* pi = &i; char* pc = dynamic_cast
(pi);//Error}int main(){ static_cast_demo(); const_cast_demo(); reinterpret_cast_demo(); dynamic_cast_demo(); return 0;}

 

转载地址:http://mudnn.baihongyu.com/

你可能感兴趣的文章
3.3双端口RAM & 多模块存储器(用于提升主存速度)
查看>>
3.4Cache
查看>>
4-5CISC和RISC
查看>>
3.2虚拟内存管理
查看>>
4.1文件系统基础
查看>>
计组-数据冒险
查看>>
4.2磁盘的结构
查看>>
程序中断方式
查看>>
DMA控制器
查看>>
2.2定点数的乘除法运算
查看>>
opencv cvtcolor函数中断异常
查看>>
摄像头、视频读取、写入
查看>>
opencv杂七杂八
查看>>
鼠标操作和滑动条操作
查看>>
用opencv实现截图
查看>>
OpenCV实现视频随机播放
查看>>
opencv访问图像像素
查看>>
opencv图像几何变化
查看>>
OpenCV图像滤波
查看>>
opencv图像阈值化
查看>>