[fpc-devel] Multiple inheritance

Ondrej Pokorny lazarus at kluug.net
Sat Aug 19 09:49:22 CEST 2017


On 19.08.2017 9:27, Sven Barth via fpc-devel wrote:
> The designers of Object Pascal decided on purpose against multiple 
> inheritance as they probably saw the problems that C++ has with them. 
> Even Java and C#, both clearly influenced by C++ don't support 
> multiple inheritance.
>
> Just think about one class in the inheritance graph reintroducing a 
> virtual method with different parameters. What will the final class do 
> then?
>
Nothing special.  The new virtual method is just a completely different 
method. Nothing to really bother about. Pascal supports overloading with 
no problems.

Actually what you get from the schema is a single inheritance chain. The 
extension classes would be automatically inserted:

TBase = class(TObject);
TBase_TAddressExtension = class(TBase);
TBase_TAddressExtension_TTagsExtension = class(TBase_TAddressExtension);
TCustomer = class(TBase_TAddressExtension_TTagsExtension);

Ondrej



More information about the fpc-devel mailing list