revised: 11/27/98, 2/14/99, 01/24/00, 07/27/02, 06/04/03, 03/04/06, 07/19/10, 07/22/14, 01/27/18

go to home page   go to next page hear noise highlighting

CHAPTER 80 — Inheritance

Object oriented languages have a feature called inheritance.

Inheritance enables you to define a new class based upon an existing class. The new class is similar to the existing class, but may have additional instance variables and methods. This makes programming easier because you can build upon an existing class instead of starting out from scratch.

Inheritance is part of the reason for the enormous success of modern software. Programmers are able to build upon previous work and to continuously improve and upgrade existing software.

Graphical user interface programming is done by using inheritance with the basic graphical classes contained in a standard library. You select the basic classes you need for a particular application. Inheritance automatically gives you most of what you need. All you need to do is add the details you need for your particular application.

This chapter discusses the syntax and semantics of inheritance using some simple examples. The next chapter continues the discussion using some larger examples.


Chapter Topics:


QUESTION 1:

Instead of creating new classes from old classes by inheritance, why not copy the source code for the old class and change it to suit your needs?


go to home page   go to next page