Single & Multiple Inheritance in C++
Douglas C. Schmidt
Professor d.schmidt@vanderbilt.edu www.dre.vanderbilt.edu/schmidt/ Department of EECS Vanderbilt University (615) 343-8197
Object-oriented programming is often defined as the combination of Abstract Data Types (ADTs) with Inheritance & Dynamic Binding Each concept addresses a different aspect of system decomposition: 1. ADTs decompose systems into two-dimensional grids of modules – Each module has public & private interfaces 2. Inheritance decomposes systems into three-dimensional hierarchies of modules – Inheritance relationships form a lattice 3. Dynamic binding enhances inheritance – e.g., defer implementation decisions until late in the design phase or even until run-time!
Copyright c 1997-2006
Vanderbilt University
1
Douglas C. Schmidt
OO Programming with C++
Douglas C. Schmidt
OO Programming with C++
Data Abstraction vs. Inheritance
DATA ABSTRACTION DATA ABSTRACTION (2 DIMENTIONAL) (2 DIMENTIONAL)
Motivation for Inheritance
Inheritance allows you to write code to handle certain cases & allows other developers to write code that handles more specialized cases, while your code continues to work Inheritance partitions a system architecture into semi-disjoint components that are related hierarchically Therefore, we may be able to modify and/or reuse sections of the inheritance hierarchy without disturbing existing code, e.g., – Change sibling subtree interfaces i.e., a consequence of inheritance – Change implementation of ancestors i.e., a consequence of data abstraction
INHERITANCE (3 DIMENTIONAL)
Copyright c 1997-2006
Vanderbilt University
2
Copyright c 1997-2006
Vanderbilt University
3
Douglas C. Schmidt
OO Programming with C++
Douglas C. Schmidt
OO Programming with C++
Inheritance Overview
A type (called a subclass or derived type) can inherit the characteristics of...
No comments