Which Method?
In addition to introducing changes in class constructor rules, MI often requires other coding adjustments. Consider the problem of extending the Show()
method to the SingingWaiter
class. Because a SingingWaiter
object has no new data members, you might think the class could just use the inherited methods. This brings up the first problem. Suppose you do omit a new version of Show()
and try to use a SingingWaiter
object to invoke an inherited Show()
method:
SingingWaiter newhire("Elise Hawks", 2005, 6, soprano);newhire.Show(); // ambiguous
With single inheritance, failing to redefine Show()
results in using the most recent ancestral definition. In this case, each direct ancestor has a Show()
function, which makes this call ambiguous. ...
Get C++ Primer Plus 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.