首页 > 其他 > 详细

dynamic_cast 的作用() the role of cynamic_cast

时间:2017-10-15 17:13:08      阅读:223      评论:0      收藏:0      [点我收藏+]

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 不安全,这个运算符会传回空指针(也就是说,基类指针或者引用没有指向一个派生类对象)。

dynamic_cast 的作用() the role of cynamic_cast

原文:http://www.cnblogs.com/1915884031A-qqcom/p/7672573.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!