C++中的type_info(中英文版)

本文介绍了C++中的std::type_info类,它用于存储类型信息,并通过typeid操作符获取。std::type_info可以用于比较类型,获取类型标识,并在多态类中确定对象的动态类型。当应用在空指针上时,会抛出bad_typeid异常。type_info对象的生命周期贯穿整个程序。
摘要由CSDN通过智能技术生成
注:上课讲的dynamic_cat与这儿的type_info都属于RTII的内容,type_info的内容如下。要注意的是,由于C++标准对于type定义的稍显粗略,故不同编译器可能会所不同。
class
<typeinfo>

std::type_info

class type_info;
Type information type

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 expressio

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值