You can't have multiple inheritance in Delphi (or Java). You can in some
types of C++. You *can* have interfaces but that doesn't solve your
problem. The reason they don't put it in is because of worry about what
happens when ancestor methods 'collide' etc..
I suggest creating a TSharedCode in each of your other objects but rather
than put stub/proxy methods in, access the methods via a public read-only
reference to TSharedCode
ie.
TComponent1 = class (TQuery)
private
FSharedCode : TSharedCode;
public
property SharedCode : TSharedCode read FSharedCode;
... (create/destroy it of course)
and then call the functions with
<some TComponent1Object>.SharedCode.SomeFunction
Mike "gonna stick with the SQL kludge" Mueller
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
> Behalf Of Mark Derricutt
> Sent: Sunday, 3 September 2000 12:39
> To: Multiple recipients of list delphi
> Subject: [DUG]: Multiple Inheritance?
>
>
> 'lo, question for the masses...
>
> I have a group of components that all share a common logic, but due to the
> nature of the components, I can't put that common logic in a masterclass,
> at the moment I have:
>
> type
> TSharedCode = class(TObject)
> TComponent1 = class(TQuery)
> TComponent2 = class(TADOQuery)
> TComponent3 = class(TSomeMemoryTableComponent)
>
> TSharedCode has a selection of methods and properties that do the actual
> grunt code, TComponent1/2/3 create an instance of TSharedCode in their
> constructor, and have stub/proxy methods defined, so I have:
>
> procedure TSharedCode.SomeFunction;
> begin
> // do stuff
> end;
>
> procedure TComponent1.SomeFunction; // this is repeated for each component
> begin
> SharedObject.SomeFunction;
> end;
>
> This makes for some messy code, having all these little stub functions, so
> was wondering if I could use multiple inheritance for this? like:
>
> type
> TComponent1 = class(TQuery, TSharedCode);
>
> This way, if I add functionality to TSharedCode, its instantly available
> to the other classes without adding new stub functions everywhere.
>
> If I had windows/delphi here at home I'd prolly load it up and try it, but
> alas no.
>
> Mark
>
> ------------------------------------------------------------------
> ---------
> New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
> Website: http://www.delphi.org.nz
> To UnSub, send email to: [EMAIL PROTECTED]
> with body of "unsubscribe delphi"
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"