C++中的type_info(中英文版)
来源:互联网 发布:手机电话号码数据库 编辑:程序博客网 时间:2024/06/07 07:07
std::type_info
class type_info;
Stores information about a type.
This type is returned by the typeid
operator (as a const-qualified lvalue). Although the dynamic type may be any class publicly derived from it.
It can be used to compare two types or to retrieve information identifying a type.typeid
can be applied to any type or typed expression.
If applied to a reference type (lvalue), the type_info returned identifies the referenced type. Anyconst
orvolatile
qualified type is identified as its unqualified type.
A typedef
type is considered the same as its aliased type.
When typeid
is applied to a reference or dereferenced pointer to an object of a polymorphic class type (a class declaring or inheriting a virtual function), it considers its dynamic type (i.e., the type of the most derived object). This requires the RTTI (Run-time type information) to be available.
When typeid
is applied to a dereferenced null pointer a bad_typeid exception is thrown.
The lifetime of the object returned by typeid
extends to the end of the program.
译文:
==============================
std::type_info
class type_info;
存储一种类型的类型信息。(译者注:包括基本类型和自定义类型)
可通过操作符typeid返回这个类型(作为常量修饰左值)。动态类型可以是任何从它派生的类型。
它可用于比较两种类型或是获取标识一个类的类型信息。
typeid能用于任何类型或是类型表达式。
如果应用于一个引用类型(左值),返回的type_info 被标识为引用类型。任何const或是volate修饰符类型被别识为无修饰类型。
typedef类型被视作其原始类型(别名类型)。
当typeid应用于引用类型或是解引用类型指针指向的一个对象,对象的类型是一个多态类型(声明或是继承了一个虚函数的一个类,【译者:一定注意这一点】),typeid可以适别这个动类型(也就是或父类指针指向了一个子类,则返回的是子类唯一识别符)。要做到一点需要RTTI的支持(译者注:GCC编译时,默认打开RTTI,其它编译器需要看其说明文档)。
当typeid应用于一个空指针时,会抛出bad_typeid异常。
由typeid获取的对象的生命周期是直至程序结束。
- C++中的type_info(中英文版)
- MSVCRT.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::type_info(class type_info c
- 《小王子》中的经典语录(中英文对照)
- 全球地名中英文对照表(C)
- 导航中的中英文切换
- c\c++复习基础要点15----c++运行时类型识别 dynamic_cast typeid type_info
- 嵌入式C的十六个问题的中英文版
- 读取文本中的数字(其中包含中英文字符)
- error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)"
- 经典电影台词(中英文对照版)
- 据说是美军军规(中英文对照版)
- COBOL经典面试题库(中英文版)
- COBOL经典面试题库(中英文版)
- 世界著名大学校训(中英文版)
- J2ME中的中英文混排
- Lucene中的中英文stop--word
- OpenERP 中的中英文术语对照
- 电路中的中英文词汇对照
- Google的Python代码风格指南(转)
- 大道至简之十四:从决定性因素到逻辑链
- 乔布斯的斯坦福演讲(双语)
- 采用CBP2MAKE工具由CODE::BLOCKS工程创建MAKEFILE文件
- 大道至简之十五:找源头,步步深入分析
- C++中的type_info(中英文版)
- C++ 新特性学习(三) — Regex库
- Panda Directx Exporter for max 插件
- Cursor和CursorAdapter中的观察者模式机制
- Hdu 3461 并查集
- 字符串匹配的Boyer-Moore算法
- Linux内核分析 - 网络[八补]:IP协议补充
- 使用javaScript解决asp.net中mvc使用ajax提交数组参数的匹配问题
- Android 避免APP启动闪黑屏(Theme和Style)