A többszörös öröklődés egy felhasználási területe: többféle viselkedés
kombinálása. Példa: INTEGER_32
, melyben benne van a
NUMERIC
, a COMPARABLE
és a
HASHABLE
. Interfészeket öröklünk, és azokat megvalósítjuk.
deferred class NUMERIC
feature
infix "+"( other: like Current ): like Current
infix "-"( other: like Current ): like Current
...
end -- class NUMERIC
deferred class COMPARABLE
feature
infix "<"( other: like Current ): like Current
infix "<="( other: like Current ): like Current
...
end -- class COMPARABLE
deferred class HASHABLE
feature
hash_code: INTEGER_32
end -- class HASHABLE
class INTEGER
inherit NUMERIC redefine infix "+", infix "-", ... end;
COMPARABLE redefine ... end;
HASHABLE redefine hash_code end
feature
...
end -- class INTEGER
Miért jó? Más OO nyelvek? Egy implementáció és több interfész öröklése?
Hogyan lehet ilyet Ada95-ben (és Ada83-ban)?