RTTI
来源:互联网 发布:公司单页网站源码 编辑:程序博客网 时间:2024/06/07 14:29
RTTI(run-time type identification) ,like exceptions ,depends on type information residing in the virtual function table. If you try to use RTTI on a class that has no virtual functions, you will get unexpected results.
for example:
//C24RTTIWithoutPolymorphism.cpp#include <cassert>#include <typeinfo>#include <iostream>using namespace std;class X { int i;public: // ...};class Y : public X { int j;public: // ...};int main() { X* xp = new Y; // the two below condition is true; assert(typeid(*xp) == typeid(X)); assert(typeid(*xp) != typeid(Y)); cin.get();}So RTTI is intended for use only with polymorphic class. Without virtual function table, the typeid() will not work;
- RTTI
- RTTI
- rtti
- RTTI
- RTTI
- RTTI
- RTTI
- RTTI
- RTTI
- RTTI
- RTTI
- RTTI
- RTTI
- RTTI
- RTTI
- RTTI
- RTTI
- RTTI
- HTML 5中几种用于在客户端本地存储数据的API之间的比较
- EXP/IMP迁移数据
- JavaScript学习笔记(二十四) 模块创建构造函数
- Vijos1459 车展
- Redmine更换主题、安装插件
- RTTI
- C++输出中文字符串
- rqnoj-407
- Java类依赖、被依赖分析工具Class Dependency Analyzer (CDA)
- 关于RGB和HSV颜色空间
- JVM内部字符编码
- android中HttpURLConnection的使用
- centos 下安装apt-get工具
- 旅行员售货问题