How is Upcasting related to Base class pointer pointing to derived class object?

A derived-class reference or pointer is Upcast to a base class. To put it another way, upcasting enables us to handle derived types as if they were their base types.

Without an explicit typecast, public inheritance is always permitted. This is a result of the base and derived classes having an is-a relationship.

Although C++ permits a base pointer to point to any object derived from that base, The pointer cannot be directly used to access all the members of the derived class we may have to use another pointer declared as a pointer to the derived type.

Base Class Pointer Pointing to Derived Class Object in C++

Prerequisite: Pointers in C++

A pointer is a data type that stores the address of other data types. Pointers can be used for base objects as well as objects of derived classes. A pointer to the object of the derived class and a pointer to the object of the base class are type-compatible (may be used in different ways). 

The pointer of Base Class pointing different objects of the derived class

Base class pointer to Derived class object 

Similar Reads

Approach:

A derived class is a class that takes some properties from its base class. It is true that a pointer of one class can point to another class, but classes must be a base and derived class, then it is possible. To access the variable of the base class, a base class pointer will be used. So, a pointer is a type of base class, and it can access all, public function and variables of the base class since the pointer is of the base class, this is known as a binding pointer. In this pointer base class is owned by the base class but points to the derived class object. The same works with derived class pointer, values are changed....

How is Upcasting related to Base class pointer pointing to derived class object?

...

Conclusion:

A derived-class reference or pointer is Upcast to a base class. To put it another way, upcasting enables us to handle derived types as if they were their base types....