May 2012
Intermediate to advanced
679 pages
16h 56m
English
It is possible for a class to derive features from two base classes. We call it as multiple inheritance. Figure 10.1 illustrates the point.
Figure 10.1 Multiple inheritance
Multiple inheritance can best be illustrated with the example of a digital clock. A digital clock derives time from one class and date from another. We have a class Date and class Time1 developed previously. The new class clock will inherit properties from both these classes. This is shown in Figure 10.2.
Notice the declaration.
class Clock: public Time1 , public Date
This declaration allows all parameters of Time1 and Date to be inherited in ...
Read now
Unlock full access