In The C# Programming Language Krzysztof Cwalina states in an annotation:
we explicitly decided not to add support for multiple inheritance
[…] the lack of multiple inheritance forced us to add the concept of
interfaces, which in turn are responsible for problems with the
evolution of the framework, deeper inheritance hierarchies, and many
other problems.
Interfaces are a core concept to OO programming languages. I don’t follow the meaning of “forced us to add the concept of interfaces”
Does Krzysztof mean that certain design decisions had to be made regarding the use of interfaces where otherwise mulitple inheritance would be used? Or, does he mean that interface‘s were introduced to C# because of a lack of multiple inheritance? Can you provide an example?
An interface is simply a base class that has no data members and only defines
public abstractmethods. For example, this would be an interface in C++:Therefore when MI is available as a language feature you can “implement” interfaces by simply deriving from them (again, C++):
Multiple inheritance in the general case gives rise to many questions and problems that don’t necessarily have a single answer, or even a good one for your particular definition of “good” (dreaded diamond, anyone?). Multiple interface implementation sidesteps most of these problems exactly because the concept of “inheriting” an interface is a very constrained special case of inheriting a full-blown class.
And this is where “forced us to add the concept of interfaces” comes in: you cannot do much OO design when constrained to single inheritance only, for example there are serious issues with not being able to reuse code when code reuse is in fact one of the most common arguments for OO. You have to do something more, and the next step is adding multiple inheritance but only for classes that satisfy the constraints of an interface.
So, I interpret Krzysztof’s quote as saying