Chapter 12. Inheritance

Table of Contents

1. Inheritance Basics
2. Reusing Code with Inheritance
3. The is Operator
4. Polymorphism
5. Abstract Classes
6. The Object class

A CLASS REPRESENTS A SET OF OBJECTS which share the same structure and behaviors. The class determines the structure of objects by specifying variables that are contained in each instance of the class, and it determines behavior by providing the instance methods that express the behavior of the objects. This is a powerful idea. However, something like this can be done in most programming languages. The central new idea in object-oriented programming -- the idea that really distinguishes it from traditional programming -- is to allow classes to express the similarities among objects that share some, but not all, of their structure and behavior. Such similarities can be expressed using inheritance and polymorphism. The topics covered in this section are fundamental aspects of object-oriented programming. Any programmer should know what is meant by the terms subclass, inheritance, and polymorphism.