ProAnswers.org

What is Downcasting ?

What is Downcasting ?

Downcasting is the casting from a general to a more specific type, i.e. casting down the hierarchy.

In object-oriented programming, downcasting or type refinement is the act of casting a reference of a base class to one of its derived classes.
In most programming languages, it is usually possible to check through RTTI whether the type of the referenced object is indeed the one being cast to or a derived type of it, and thus issue an error if it is not the case.