Answer the question
In order to leave comments, you need to log in
Can two classes be combined into a common derived class?
I study OOP, specifically now - inheritance. I got the general concept, but the question is about practical application.
Let's say there is a base class - Man. He has two derivatives - the driver and the military.
The essence of the question: is it possible to combine two such subclasses, inside a superclass? Is this implementable in C#, and if so, how much (if at all) will it complicate further support?
Answer the question
In order to leave comments, you need to log in
He asked, he answered.
Yes, in theory you can. This is called multiple inheritance.
Multiple inheritance is a potential source of errors that can arise from having the same method names in ancestors. In languages that are positioned as the heirs of C ++ (Java, C # and others), it was decided to abandon multiple inheritance in favor of interfaces.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question