dynamic_cast 的作用() the role of cynamic_cast

cast a base calss pointer (or reference) to the inheritance class pointer, dynamic_cast will be based on the base class pointer is really pointing to the inheritance class pointer to do the appropriate treatment

将一个基类对象指针(或引用)cast到继承类指针,dynamic_cast会根据基类指针是否真正指向继承类指针来做相应处理

the dynamic_cast operator can determine the actual type at execution time. if the downcast is safe(that is, if the base class pointer or reference does point to a derived class object or reference does point to a derived class object)this operator will return the appropriate converted pointer. if downcast is unsafe, the operator will return a null pointer(that is, the base class pointer or reference does not point to a derived class object)

dynamic_cast运算符可以在执行期决定真正的类型。如果 downcast 是安全的(也就说,如果基类指针或者引用确实指向一个派生类对象)这个运算符会传回适当转型过的指针。如果 downcast 不安全,这个运算符会传回空指针(也就是说,基类指针或者引用没有指向一个派生类对象)。

转载于:https://www.cnblogs.com/1915884031A-qqcom/p/7672573.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值