upcasting in c++
Upcasting 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.
C++ allows that a derived class pointer (or reference) to be treated as a base class pointer. This is upcasting.
Downcasting is an opposite process, which consists of converting base class pointer (or reference) to derived class pointer.
C++ Upcasting and Downcasting should not be understood as a simple casting of different data types. It can lead to great confusion.
In this topic, we will use the following hierarchy of classes: