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?
ringa_lee2017-05-31 10:36:49
0
2
2257
"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?
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
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
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
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