码迷,mamicode.com
首页 > 其他好文 > 详细

dynamic_cast 的作用() the role of cynamic_cast

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

标签:iat   this   convert   类型   tin   exe   派生   运算符   类对象   

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

标签:iat   this   convert   类型   tin   exe   派生   运算符   类对象   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!