> HI,
Are ther any pitfalls for dynamic cast in type safe downcasting..
What exactly do you mean by "pitfalls"?
dynamic_cast is a runtime casting operator. Because the cast is
evaluated at runtime, it is probable that the cast may fail even though
the code compiles. In the case of casting object pointers, the failed
cast will result in a NULL pointer. In the case of casting object
references, the failed cast will result in throwing a bad_cast
exception object. It is very important to note that casting across or
down the class hierarchy using
dynamic_cast is only possible when the base class is a polymorphic
type, that is, the class has at least one virtual method.
Regards,
Srini