 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
| • |
A
downcast operation is when a pointer to a direct or
|
|
|
indirect
base class is converted to a pointer to a derived
|
|
|
class.
|
|
|
| • |
The
static_cast operator syntax is
|
|
|
| • |
static_cast<type*>(expr)
|
|
|
| • |
where expr is an expression pointing
to a direct or
|
|
|
indirect
base class object and type is a derived class.
|
|
|
| • |
The
result of the cast operation is that expr is converted to
|
|
|
a
pointer to the specified type, converting the static type of
|
|
one
pointer into another.
|
|
|
| • |
As
such, it depends on the programmer to ensure that the
|
|
|
conversion
is correct. It is inherently unsafe because no
|
|
|
run
time type information is used.
|
|