Inheritance

3/31/98


Click here to start


Table of Contents

Inheritance

Overview

Philosophical note

Inheritance

Why use inheritance?

The classic example

Specifying inheritance in C++

What it means

When to use inheritance

The Liskov substitution principle

Examples

Is a square a (kind of) polygon?

Squares and polygons

Other examples

Implementation

Access to base class

Inheritance of members

Classes are scopes

Conversion examples

Why allow s = c?

A tiny vector class

A vector class with explicit bounds

Treating a BVec as a Vector

Why does this example work?

This example is ...

Where is the violation?

Does operator[] violate the principle?

Cleaning up Bvec

Examples of inheritance

Examples where inheritance is inappropriate

Squares and polygons

Other non-inheritance situations

Review

What’s next

Author: Andrew Koenig

Email: ark@research.att.com

Home Page: http://www.research.att.com/info/ark