Multiple Inheritance


          Class A inherits B, C, and D
          
Why is this an issue?

Multiple Inheritance


          Class A inherits B, C, and D
          
Inheirted fields/methods may have same names but conflicting definitions.

There are five approaches to handle it when designing an object oriented programming language.

Multiple Inheritance

  1. Forbid it
  2. Allow and determine by the order of Inheritance
  3. 
                Class A inherits B, C, and D // if conflicting, B wins
                Class A inherits C, B, and D // if conflicting, C wins
                
  4. Allow and specify in class definition
  5. 
                Class A inherits B, C (field x), and D(method foo)
                
  6. Allow and specify which one to use when calling conflicting fields/methods
  7. 
                A a = new A(); a(C).x = 4; a(D).foo();
                
  8. Allow and specify when instantiating the object
  9. 
                A(B.x, D.foo) a = new A() or A a = new A(B.x, D.foo)