CIS 29 - Notes for Tuesday, 2/2

Announcements and Reminders

Recording

Inheritance Review

Inheritance, virtual functions, polymorphism, abstract classes

Example

Multiple Inheritance

Multiple inheritance permits a class to be derived from two (or more) other classes. In this way the derived classes inherits the members and properties of both (or more) base classes.

Example 9-1 – Multiple Inheritance

Multiple Inheritance with Virtual Base Classes


Example 9-2 - Multiple Inheritance with Virtual Base classes

Dynamic Cast

A dynamic_cast is used with inheritance to cast a base class pointer or reference to a derived class pointer or reference.  This is called downcasting.  In order for this to succeed, the base class must be polymorphic (contains a virtual function).

Reference:  Upcasting and Downcasting

Example 4-4 – dynamic_cast