nWe can assign pointers to derived class objects to point
to base class objects. We can also
use derived class objects to
initialize references to base class objects.
nUsing this account class hierarchy, whenever we need a pointer to an account object, we can use a pointer to a checking, student, or savings object. This is called upcasting even
though no cast operation is necessary.
nThis is because every
checking, student, and savings object
contains an account object. When we are pointing to a checking, student, or savings object, we are also pointing to an account object.
nWhen we are pointing to an account object, we do not have access to a checking, student, or savings objects.