Inheritance

When you display a class object that has virtual base classes, the members of the virtual base class are displayed for each inheritance path, even though only one instance of those members is stored. You can access members of an object through a pointer to the object, and you can call virtual functions through a pointer.

For example, when the Employee class defines a virtual function that is named computePay, which is redefined in the class that inherits from Employee, you can call computePay through a pointer to Employee and have the proper function executed:

>? empPtr->computePay()

You can cast a pointer to a derived class object into a pointer to a base class object; the reverse conversion is not permitted. For example, if the class List is derived from the class Collection, the cast (Collection *)pListCustomer is valid, but the cast (List *)pCollectClients is illegal.