Refinement in C++

Now let us go back to C++. As we noted in the first part of this chapter, the default in C++ is to perform replacement. However, refinement, that is the combination of parent and child behavior, can be simulated by having the child class invoke the code from the parent class.

This is shown on this slide. Here the addCard method in the child explicitly names the addCard method in the parent, using the fully qualified name.

Notice that this is similar but not quite the same as the Beta example. In the Beta example the parent wraps around the child behavior, here the child behavior wraps around the parent code.

[audio] [real] Text to accompany slide17, in Chapter 11 of An Introduction to Object-Oriented Programming