打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
C++类型转换
#include <iostream>using namespace std;//测试int 和 void*的相互转化void test_voidpointer(void *data){ int d = reinterpret_cast<int>(data); cout << d << endl;}//定义连个无关类A, Bclass A{};class B{};int _tmain(int argc, _TCHAR* argv[]){ //void* 和in的相互转化,这里应该注意一下64位平台和32位平台指针的大小不同 test_voidpointer(reinterpret_cast<void *>(20)); //A a; B b; //a = reinterpret_cast<A>(b); //编译通不过,b不知指针或者引用 //下面是指针或引用的转化 A *pa = reinterpret_cast<A*>(&b); A &ra = reinterpret_cast<A&>(b); system("pause"); return 0;}  
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
C++中的4种显示类型转换(草稿)
static_cast, dynamic_cast, reinterpret_cast, const_cast区别比较
c、c++指针和整型的互相转换
C++中四种类型转换方式
使用标准C++的类型转换符:static_cast、dynamic_cast、reinterpret_cast、和const_cast。
c++中主要四种强制类型转换
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服