Solved

Multiple inheritance

Posted on 2002-04-09
9
343 Views
Last Modified: 2010-04-04
Is there a way to implement multiple inheritance in Delphi?
0
Comment
Question by:barzangy
9 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6928120
what does you mean with multiple inheritance?
0
 
LVL 3

Accepted Solution

by:
raidos earned 50 total points
ID: 6928138
The VCL does NOT support multiple inheritance, unless your working with Interfaces...

Regards
//raidos
0
 

Author Comment

by:barzangy
ID: 6928142
Well in c++ you have

class first {
  public void do1();
}

class second {
  public void do2();
}

class third : public first, public second {
}

Here class third inherits both "do1" and "do2"
0
 

Author Comment

by:barzangy
ID: 6928147
Raidos: Do you mean it is possible to do that using interfaces? and if yes, can you show one example?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 14

Expert Comment

by:AvonWyss
ID: 6928203
There is no multiple inheritance in Delphi (just like in Java, C# and most other OOP languages). An interface declares what functionality is suported by a class. So, for your example, you can define bot do1 and do2 as interfaces and have one class implement both interfaces. This will work and provide the wanted functionality.
0
 
LVL 3

Expert Comment

by:SteveWaite
ID: 6928630
0
 
LVL 3

Expert Comment

by:lopem
ID: 6928737
barzangy,

I dont know how multiple inheritance can improve code. Can you give me an example? I know C++ has multiple inheritance. Delphi doesnt.

best regards.
Manuel Lopez (lopem)
0
 
LVL 3

Expert Comment

by:SteveWaite
ID: 6928854
sorry, look at com lesson 3 in that link i posted
0
 
LVL 26

Expert Comment

by:Russell Libby
ID: 6929023

A good example of 'mi' using COM interfaces (if you have the source) is in the OleCtnrs.pas file (TOleContainer). The TOleContainer inherits from multiple COM classes. As the others have mentioned, Delphi itself does not support 'mi using Delphi class objects.

ie: type foo1 = class(TObject, IUnknown, IEtc..) // OK
    type foo2 = class(TObject, TStringList) // NOT OK

-------
Russell
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now