Thinking in C++ Vol 2 - Practical Programming |
Prev |
Home |
Next |
Although normally you upcast a pointer to a base class and
then use the generic interface of that base class (via virtual functions),
occasionally you get into a corner where things can be more effective if you
know the dynamic type of the object pointed to by a base pointer, and that s
what RTTI provides. The most common misuse may come from the programmer who
doesn t understand virtual functions and uses RTTI to do type-check coding
instead. The philosophy of C++ seems to be to provide you with powerful tools
and guard for type violations and integrity, but if you want to deliberately
misuse or get around a language feature, there s nothing to stop you. Sometimes
a slight burn is the fastest way to gain experience.
Thinking in C++ Vol 2 - Practical Programming |
Prev |
Home |
Next |