 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
| • |
The
dynamic_cast operator relies on information stored in
|
|
an
object by the compiler whenever a direct or indirect
|
|
|
base
class contains a virtual function. This cast is used
|
|
|
when
downcasting to determine at run time if the
|
|
|
downcast
is valid or not.
|
|
|
| • |
The
dynamic_cast operator syntax is
|
|
|
| • |
dynamic_cast<type*>(expr)
|
|
|
| • |
where expr is an expression pointing
to a direct or
|
|
|
indirect
base class object and type is a derived class.
|
|
|
| • |
expr
is converted to a pointer of the specified type if the
|
|
|
dynamic
type of the object pointed to is that type or is a
|
|
|
type
derived from that type. Otherwise, the result of the
|
|
|
cast
operation is zero.
|
|