Objects vs ADTs: Inheritance

OOP exploits inheritance in the definition of types. Using inheritance, the programmer can reuse the behavior of a class in the definition of a new class (without copying the code for the original class). Subclasses inherit the operations of their parent class, while adding new operations and instance variables.

Example: Imagine a program that processes personnel records at the UR. There may be a type PERSON that includes information about each person on campus, such as their name, phone number, address, and SSN. This type may include operations that return various pieces of information about a person given an SSN. We can build on the PERSON type to create new types STUDENT, FACULTY, and STAFF. The STUDENT type might include the year of graduation, their parent's address, and their GPA. The FACULTY type might include their department and years of service. By using the PERSON type as a base type, we don't have to rewrite any operations already supplied as part of the PERSON type for the new types STUDENT and FACULTY.