You will learn the following in this chapter:
Inheritance is a fundamental element of object-oriented programming (OOP) that promotes code reuse. Any time you can reuse a piece of code that has already been written, tested , and debugged , you enhance programmer productivity.
The basic idea behind inheritance is that although there may be unique properties that precisely define an object, many objects share common properties with other objects. For example, consider a building object. All buildings have certain properties in common. Each has a street address, a property tax rate and amount, a number of square feet, and so forth. However, specific types of buildings have additional properties that distinguish them from one another. Most building codes, for example, require commercial buildings to have a fixed number of parking spots per square foot of lease space. A private home, however, does not have that requirement. Likewise, a private home has properties, such as the number of bedrooms, that don't apply to a commercial building.
This chapter discusses how you can use inheritance to extend the functionality of a class.