Search code examples
inheritanceoopconceptual

Conception of inheritance in object-oriented languages


I was discussing multiple inheritance vs. single inheritance with a friend of mine, and discovered that plainly, my conception of Object-Oriented design is completely different than his. I am mostly an Obj-C programmer, so Multiple Inheritance is not something I use daily. He is mostly a C++ programmer under Windows/PSP, so we probably use different concepts on a day-to-day basis.

He actually brought the following subject : What does a new human being inherit from?

My conception of that was that there would be a Human class, and the new being would inherit from that class and get some instance variables (such as his DNA and others) from his two parents.

His conception was that the child would inherit from his two parents, in order to get the methods of his parents.

And now I'm kind of confused, because honestly... Inheriting from objects? Isn't inheritance used to inherit from classes which contain methods common to a certain group of objects? This argument really confused me to no end.


Solution

  • The parents are also humans, which are part of the family of creatures called mammals. Your thoughts seem most logical to me.

    public class Human extends Mammal implements HunterGatherer, Speech, CognitiveThought {
    
        public Human(Human mother, Human father) {
            super(mother, father);
            // ...
        }
    
        // ...
    }
    

    Certainly I can't see:

    public class Human extends Mother, Father { ... }
    

    I see the mother and father as being rather involved in the construction of their child, all three are humans.