October 2011
Beginner to intermediate
1200 pages
35h 33m
English
Suppose you begin by publicly deriving SingingWaiter from Singer and Waiter:
class SingingWaiter: public Singer, public Waiter {...};
Because both Singer and Waiter inherit a Worker component, SingingWaiter winds up with two Worker components (see Figure 14.4).
Figure 14.4. Inheriting two base-class objects.

As you might expect, this raises problems. For example, ordinarily you can assign the address of a derived-class object to a base-class pointer, but this becomes ambiguous now:
SingingWaiter ed;Worker * pw = &ed; // ambiguous
Normally, such an assignment sets a base-class pointer to the address of the base-class object ...
Read now
Unlock full access