design patterns - Why is diamond of death and not triangle of death -


this question has answer here:

i've seen lot examples illustrate dangerous of multiple inheritance.

the example class b , c extends class , class d extends both b , c.

b , c both override method a, example, equals();

then when call d.equals(); doesn't know 1 parent should called

provided equals() not overridden in d.

from can see, isn't class in example redundant? if remove hierarchy , @ b , c, if b , c both have method called equals(), when d extends b , c, still have same problem, isn't triangle of death?

i not sure if assumed cause compile time error in other language.

hope can clarify me.

if d extends b , c , not overrides method equals(), implemented in b , c, there no ambiguity - d can use b.equals() or c.equals().

with diamond structure on other hand, if d calls a.equals() , both b , c override it, don't know method should invoked b.equals() or c.equals().


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -