In this Lab we discuss two of the most important capabilities of
object-oriented programming-inheritance and polymorphism.
Inheritance is a form of software reusability in which new classes are
created from existing classes by absorbing their attributes and behaviors,
and overriding or embellishing these with capabilities the new classes require.
Software reusability saves time in program development.
It encourages the reuse of proven and debugged high-quality software, thus
reducing programs after a system becomes functional. These are exciting
possibilities. Polymorphism enables us to write programs in a general fashion to
handle a wide variety of existing and yet-to-be-specified related classes.
Inheritance and polymorphism are effective techniques for managing software
complexity.
Goal:
1. To be able to create new classes by inheriting from existing classes.
2. To understand how inheritance promotes software reusability.
3. To understand the notions of base classes and derived classes.
4. To be able to use multiple inheritance to derive a class from several base
classes.
1. Relationship between Base Classes and Derived Classes
2. Three-Level Inheritance Hierarchy
3. Constructors and Destructors in Derived Classes
Goal:
1. To understand the notion of polymorphism.
2. To understand how declare and use virtual functions to effect polymorphism.
3. To understand the distinction between abstract classes and concrete classes.
4. To learn how to declare pure virtual functions to create abstract classes.
5. To appreciate how polymorphism makes systems extensible and maintainable.
6. To understand how C++ implements virtual functions and dynamic binding
"under the hood"