dynamic_cast and DYNAMIC_DOWNCAST

DYNAMIC_DOWNCAST(class, pointer )
class: The name of a class.
pointer: A pointer to be cast to a pointer to an object of type class.

The macro will cast the pointer parameter to a pointer to an object of the class parameter's type.

If the object referenced by the pointer is a "kind of" the identified class, the macro returns the appropriate pointer. If it is not a legal cast, the macro returns NULL.

dynamic_cast <type-id> (expression)

Converts the operand expression to an object of type type-id.   an "upcast" is permitted. that is, you can assign a pointer to derived class to a pointer to its parent class.  

 

posted on 2012-12-18 16:16  Ricky.yi  阅读(264)  评论(0编辑  收藏  举报

导航