Friday, February 19, 2010

Q. What potential problems can arise from typecasting a base class pointer


into a derived class pointer so that the derived class's member functions

can be called?

A. Syntactically this is allowable. There is always the possibility of

a base pointer actually pointing to a base class. If this is

typecast to a derived type, the method being called may not exist

in the base class. Therefore, you would be grabbing the address of

a function that does not exist.

No comments:

Post a Comment