search

Home  >  Q&A  >  body text

c# - "A class can directly inherit multiple interfaces, but can only directly inherit one class (including abstract classes)." Isn't it inconsistent with C++'s multiple inheritance?

"A class can directly inherit multiple interfaces, but can only directly inherit one class (including abstract class)." Isn't it inconsistent with C's multiple inheritance?

ringa_leeringa_lee2723 days ago2251

reply all(2)I'll reply

  • 某草草

    某草草2017-05-31 10:38:49

    It should be that a class intelligently inherits from a class (including abstract classes), but can implement multiple interfaces
    Inheritance is direct inheritance, and interfaces are certain specifications. I follow certain specifications
    I think this is a better understanding

    c++ is originally a Simular system, so I won’t talk about it
    Multiple inheritance doesn’t mean much

    reply
    0
  • 黄舟

    黄舟2017-05-31 10:38:49

    C++’s multiple inheritance is truly multiple inheritance, more powerful, but also less easy to use. Therefore, languages ​​such as Java simply do not allow inheritance of multiple base classes. They can only inherit one base class and implement multiple interfaces. I can’t say which of these two methods is better, but they each have their own merits. I remember it was said in "CLR via C#" that in order to avoid multiple inheritance, C# can only inherit a single class, which resulted in many pitfalls. Anyway, if you are not a language expert, there is usually this compromise solution, and we can use it

    reply
    0
  • Cancelreply