Overriding Functions

As you've seen, a derived class can override the functions of its superclass. Member functions of the derived class can even call the functions of the superclass—including those implementations they are overriding. Figure 22.3 shows the possible variations.

Figure 22.3. Calls to functions in a derived class.

This diagram shows an object instance, which consists of the derived class and its superclass. When a function outside the object calls on SomeFunction(), the call is handled completely by the derived class and is not passed on to the corresponding superclass implementation. When a function outside the object calls on ...

Get SAMS Teach Yourself C++ in 10 Minutes SECOND EDITION now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.