Saturday, October 23, 2010

Does multiple inheritance exists in Delphi?

Sometimes it is asked - Delphi supports multiple inheritance or not?

and the answer which usually comes out is - Yes via interfaces, but the problem here is can we really say that implementing an interface actually achieves multiple inheritance in real sense or is it something else. Well the answer to this confusion is that 'No' we cannot say that implementing an interface is a way to achieve multiple inheritance because the first promise that multiple inheritance or inheritance in itself wants is that not only the declaration but also some of the behaviour should get inherited by the child class from the parent class/classes else just by suggesting a declaration of what should be achieved by a child class can never be inheritance. It is as simple as considering the analogy a child inherits some features from both mother and father but its never that a implementation is not inherited from any of the two.

Using interfaces is simply a way of allowing a boundation to the inheriting class to implement certain features so that it meets certain criteria nothing more than that. So the only language to implement multiple inheritance successfully in its real sense is C++ as of now and as per my knowledge. Delphi goes the way Java or C# tried to achieve the similar functionality via interfaces.

No comments: