An Introduction to Object-Oriented Programming

By Timothy Budd

Study Guide for Chapter 8


Learning Objectives

The C++ implementation of the card game Solitaire is discussed as an illustration of some of the most important concepts of object-oriented programming: inheritance and overriding.

After reading this chapter, you should be able to:


Study Questions

You may wish to use the print or save as command on your web browser to produce a copy of this study guide. That way you can fill in the answers to the questions as part of your assimilating the information you learn as you read the material.
  1. What data values are maintained by class Card? What behaviors can a card perform? (That is, what methods are implemented by the class Card?)

  2. Explain why the suit and rank data fields are declared as private.

  3. What is a default constructor? What is a copy constructor?

  4. What is an accessor function? What is what advantage of using an accessor function as opposed to direct access to a data member?

  5. Why might you want to make accessor functions into inline functions? What factors should you consider in deciding whether to declare a function in an inline fashion?

  6. What are the 13 different card piles that are used in the solitare game?

  7. What is a virtual member function? Describe the five virtual functions implemented in class CardPile and overridden in at least one child class.

  8. How does the use of inheritance reduce the amount of code that would otherwise be necessary to implement the various types of card piles?

  9. Explain the difference between overriding used for replacment and overriding used for refinement. Find another example of each in the methods associated with class CardPile and its various subclasses.

  10. Explain how polymorphism is exhibited in the solitare game application.


Contents copyright Timothy Budd, 1995.