Team LiB
Previous Section Next Section

Chapter 15. Object-Oriented Programming

 

Contents

 

Section 15.1 OOP: An Overview

 

Section 15.2 Defining Base and Derived Classes

 

Section 15.3 Virtual Functions

 

Section 15.4 Abstract Base Classes

 

Section 15.5 Access Control and Inheritance

 

Section 15.6 Class Scope under Inheritance

 

Section 15.7 Constructors and Copy Control

 

Section 15.8 Containers and Inheritance

 

Section 15.9 Text Queries Revisited

 

Chapter Summary

 

Defined Terms

 

Object-oriented programming is based on three fundamental concepts: data abstraction, which we covered in Chapter 7, and inheritance and dynamic binding, which we’ll cover in this chapter.

 

Inheritance and dynamic binding affect how we write our programs in two ways: They make it easier to define new classes that are similar, but not identical, to other classes, and they make it easier for us to write programs that can ignore the details of how those similar types differ.

 

Many applications include concepts that are related to but slightly different from one another. For example, our bookstore might offer different pricing strategies for different books. Some books might be sold only at a given price. Others might be sold subject to a discount. We might give a discount to purchasers who buy a specified number of copies of the book. Or we might give a discount for only the first few copies purchased but charge full price for any bought beyond a given limit, and so on. Object-oriented programming (OOP) is a good match to this kind of application.

 
Team LiB
Previous Section Next Section