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

posted @ 2017-10-15 16:24  diamondDemand  阅读(194)  评论(0编辑  收藏  举报