Chapter 6. Inheritance

 <  Day Day Up  >  

In OOP, inheritance is a formal relationship between two or more classes, wherein one class borrows (or inherits ) the property and method definitions of another class. In the practical, technical sense, inheritance simply lets one class make use of the code in another class.

But the term inheritance implies much more than code reuse. Inheritance is as much an intellectual tool as it is a technical tool. It lets programmers conceptualize a group of classes in hierarchical terms. In biology, inheritance is a genetic process through which one living creature passes on traits to another. You are said to have inherited your mother's eyes or your father's nose, even though you don't look exactly like either of your parents. In OOP, inheritance has a similar connotation. It lets a class look and feel in many ways like another class, while adding its own unique features.

We'll consider the benefits of, and alternatives to, inheritance near the end of this chapter, under "The Theory of Inheritance." But first, we need to study the syntax and general use of inheritance.

 <  Day Day Up  >  


Essential ActionScript 2.0
Essential ActionScript 2.0
ISBN: 0596006527
EAN: 2147483647
Year: 2004
Pages: 177
Authors: Colin Moock

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net