dynamic_cast

Syntax:

    dynamic_cast<reference> (object);
    dynamic_cast<pointer> (object);

The dynamic_cast keyword casts a datum from one pointer or reference type to another, performing a runtime check to ensure the validity of the cast. If you attempt to cast to pointer to a type that is not a type of actual object, the result of the cast will be NULL. If you attempt to cast to reference to a type that is not a type of actual object, the cast will throw bad_cast exception.

Related Topics: const_cast, reinterpret_cast, static_cast