 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
| • |
The
dynamic_cast operator is able to determine whether or
|
|
not
an object is a member of a hierarchy. This can be
|
|
|
useful
to determine the ancestors of a class. On the other
|
|
|
hand,
the typeid operator is only able to determine if an
|
|
|
object
is of a particular type or not.
|
|
|
| • |
It
is best to avoid using RTTI because it inherently ties the
|
|
|
application
to the types of objects that it is processing.
|
|
|
Writing
code independent of the type being pointed or
|
|
|
referred
to provides cleaner code that will be easier to
|
|
|
maintain.
|
|
|
| • |
Designs
that need to use RTTI should act as a warning
|
|
|
signal
that a better design using virtual functions may be
|
|
|
possible.
|
|