Introduction

 < Day Day Up > 



In this chapter you will learn how to create new class types that derive some or all of their behavior by inheriting that behavior from one or more pre-existing class types. A class that inherits the functionality of another class is referred to as a subclass or derived class; the class whose behavior is inherited is referred to as the superclass or base class. Inheritance is a powerful tool that, when combined with compositional design, opens seemingly endless design possibilities.

We have a lot to talk about in this chapter. The three access specifiers public, protected, and private will now be used to specify how base class members are to be accessed from derived class objects. You use the access specifiers to specify public, protected, or private inheritance.

You will learn how to call a base class constructor from a derived class initializer list, how to apply the virtual keyword to functions, and how to implement virtual functions that can be overridden in derived classes. You will learn how to create abstract base classes that contain pure virtual functions. Once you learn how to create abstract base classes I will show you how to inherit and implement these abstract base class interfaces in derived classes and use pointers to abstract base classes to call functions on derived class objects. You will learn the difference between function overloading and function overriding. And just when you think you have had enough I will show you how to inherit from more than one class!

In support of the material presented here I will show you how to extend the UML class diagram to express inheritance relationships.



 < Day Day Up > 



C++ for Artists. The Art, Philosophy, and Science of Object-Oriented Programming
C++ For Artists: The Art, Philosophy, And Science Of Object-Oriented Programming
ISBN: 1932504028
EAN: 2147483647
Year: 2003
Pages: 340
Authors: Rick Miller

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net