C++ 获取对象类型
2024-08-31 00:11:33
在入门C++过程中,我们经常会遇到无法判断对象类型的情况。
头文件( VS编译器 )
#include <typeinfo>
typeid(对象).name();
例子:
const int a = , &b = a;
auto e = a;
auto d = b;
MyClass c;
MyStruct s;
cout << typeid(a).name() << endl; // int
cout << typeid(&b).name() << endl;// int const *
cout << typeid(e).name() << endl; // int
cout << typeid(d).name() << endl; // int
cout << typeid(c).name() << endl; // class MyClass
cout << typeid(s).name() << endl; // Struct MyStruct
最新文章
- Android ViewPager 用法
- [转]Linux df 命令不更新磁盘数据空间使用情况的解决办法
- pycharm active code
- Win7下同时使用有线和无线时的优先级设置
- sql存在一个表而不在另一个表中的数据
- mtu
- javascript实现ajax
- FFmpeg资料来源简单分析:libswscale的sws_getContext()
- OPENWRT make menuconfig错误之一
- Python 多线程进程高级指南(二)
- Django 缓存模块 page_cache 源码阅读
- nginx系列8:反向代理和负载均衡原理
- 洛谷P4092 [HEOI2016/TJOI2016]树 并查集/树链剖分+线段树
- [C#学习笔记]你真的理解拆箱装箱吗?
- A - 确定比赛名次(拓扑)
- BZOJ1975 SDOI2010魔法猪学院
- 设置使用的python版本
- 用Python 3写的一个Spider小爬虫(使用内置urllib模块and正则表达式)
- hdu5985[概率dp] 2016青岛icpc现场赛
- java在线聊天项目1.3版设计好友列表框功能补充,因只要用户登录就发送一串新列表,导致不同客户端好友列表不同问题