1Upcasting and downcasting are an important part of C++. Upcasting and downcasting give a possibility to build complicated programs with a simple syntax. It can be achieved by using Polymorphism.
2
3C++ allows that a derived class pointer (or reference) to be treated as a base class pointer. This is upcasting.
4
5Downcasting is an opposite process, which consists of converting base class pointer (or reference) to derived class pointer.
6
7C++ Upcasting and Downcasting should not be understood as a simple casting of different data types. It can lead to great confusion.
8
9In this topic, we will use the following hierarchy of classes:
10