Multiple inheritance

hey folks,

Here's another question on a wonderful Monday ;-))

I want to do this :
 TfrmNewCustomer = class(TForm, TGlobalNames)

Because I want TfrmNewCustomer to inherit from both TForm and from TGlobalNames...I can't. The compiler says

"[Error] usrNewCustomerDialog.pas(10): Interface type required"

Why?


Regards,

GOMF
GOMFAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

King_DavidCommented:
Delphi allows single inheritance only.
Multiple inheritance is allowed with
Interfaces only.
0
GOMFAuthor Commented:
uhm, yick...ok then..

If I create a class that inherits from TForm and then a new class again that inherits from TGlobalNames..I get the same right ?
0
King_DavidCommented:
I'm sorry but No!
Try it and you'll see why not.
0
sburckCommented:
What I do in a case like this is inherit from one of them, and add a private copy of the other, whichever I need to get to less often, and then publish the properties of the not-inherited one.

In your case:

TTfrmNewCustomer = class(TForm)
private
     fncgn : TGlobalNames;

....
published
    property foo : whatevertype read fncgn.foo write fncgn.foo;

This is as close as you get to multiple inheritance in Delphi.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AttarSoftwareCommented:
There is a huge debate as to whether you need multiple inheritance, or whether the clean way is to do it as sburck states above.  Java doesn't have multiple inheritance either for the same reasons...

Without proper documentation, it is very easy to make unfollowable, and therefore unfixable code...

Tim.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.