From d0e539d431580476fcdf0fb71a75266940616a43 Mon Sep 17 00:00:00 2001 From: bmeyer Date: Fri, 10 Oct 2014 16:13:17 +0000 Subject: [PATCH] Author:bmeyer Date:2014-10-10T16:13:17.000000Z git-svn-id: https://svn.eiffel.com/eiffel-org/trunk@1395 abb3cda0-5349-4a8f-a601-0c33ac3a8c38 --- .../current/draft/multiple-inheritance.wiki | 43 +++++++++++++++++-- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/documentation/current/draft/multiple-inheritance.wiki b/documentation/current/draft/multiple-inheritance.wiki index f85b5cb9..d435f25e 100644 --- a/documentation/current/draft/multiple-inheritance.wiki +++ b/documentation/current/draft/multiple-inheritance.wiki @@ -1,14 +1,49 @@ [[Property:title|Multiple inheritance]] [[Property:weight|0]] [[Property:uuid|7f54afce-fd1d-fba7-7a55-f74604ea9846]] -

Multiple inheritance: overview

+

Multiple inheritance: definition

-Multiple inheritance is a mechanism for combining abstractions. It lets you define a class by extending or specializing two or more classes, not just one as in single inheritance. +Multiple inheritance is a mechanism for combining abstractions. It lets you define a class by extending or specializing two or more classes, not just one as in single inheritance. For example you might define a multi_function printer as the combination of a printer and a scanner. -Multiple inheritance sometimes has the reputation of being complicated or even messy, but there is no such problem in Eiffel. "Name clashes", for example, are not a big deal: if classes A and B both have a feature with the same name f and class C inherits from both, +Multiple inheritance sometimes has the reputation of being complicated or even messy, but there is no such problem in Eiffel. "Name clashes", for example, are not a big deal: if classes A and B both have a feature with the same name f and class C inherits from both, you can either specify that they should be merged, or keep them separate through the rename mechanism. Details below. +

Multiple inheritance basics

+ +Multiple inheritance happens as soon as you list more than one class in the inherit clause at the beginning of a class. For example: -class feature end + class PRINTER feature + ... Here the features specific to printers ... + end + + class SCANNER feature + ... Here the features specific to scanners ... + end + + class MULTI_FUNCTION_PRINTER inherit + PRINTER + SCANNER + feature + ... Here the features specific to printer-scanners ... + end +As with single inheritance, the new class has access to the parent features, except that here they are features of two different parents. For example if PRINTER has feature and SCANNER has features scan and scanned, then the feature clause of SCANNER can include + + + scan_and_print + -- Scan a page and print it. + do + scan -- Leaves result of scan in `scanned' + print (scanned) + end + + + + + + + + + +