Multiple Inheritance, C++ and Same Method Signature in Multiple Super Classes

后端 未结 5 1406
伪装坚强ぢ
伪装坚强ぢ 2021-01-31 18:42

I have no experience in C++, and I come from a Java background. Lately, I was asked in an interview on why Java would not allow multiple inheritence and the answer was pretty ea

5条回答
  •  我在风中等你
    2021-01-31 18:54

    There is nothing about multiple class inheritance that allows this. Java produces the same problem with interfaces.

    public interface A {
        public void doStuff();
    }
    public interface B {
        public void doStuff();
    }
    public class C implements A, B {}
    

    The simple answer is that the compiler throws an error on it.

提交回复
热议问题