Serial and Multiple Inheritance


By a serial inheritance is meant that each derived class has only one parent. A serial inheritance may have any one of the three access types with respect to its base: private, protected and public. What a class is a serial extension, the constructors and the destructors of the derived class are based upon the constructors and the destructors of the single base class.

Each of the following is an example of one of these three types of extension: dateprvt.cpp, dateprot.cpp, and datepubl.cpp

It is possible for a class to be derived from several classes. This is called a multiple inheritance or a multiple derivation. In a multiple derivation each extension does not need to have the same access level. When a class has a multiple extension, the constructors and the destructors are based upon the constructors and the destructors of the multiple base classes just like in a serial derivation.

There are some programmers who say that if you need a multiple inheritance, you have designed your program incorrectly. Whether this is true or not, it is still possible to define a multiple inheritance in C++. In fact you will see later that the entire C++ I/O system is based upon multiple inheritances.

For examples see multextn.cpp and multext2.cpp




Intermediate Business Programming with C++
Intermediate Business Programming with C++
ISBN: 738453099
EAN: N/A
Year: 2007
Pages: 142

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