[DGD] Inheriting the same program twice

Par Winzell zell at skotos.net
Tue Apr 19 13:48:01 CEST 2005


Petter,

>> If A inherits B... And B inherits X... There shouldn't be any need for
>> A to inherit X, as it already can call functions defined in X by
>> inheriting B.
> 
> But X also defines a data field. The functions in X operates mainly on 
> this data field. In A I have need for two such data fields.

Well, DGD allows the inheritance tree you describe, and it's a perfectly 
good alternative to using prototypes... if B needs to make calls on X, 
it can either prototype the functions and trust that its inheritor (the 
eventual A) will inherit X -- basically making it an abstract class -- 
or it can directly inherit X.

Unfortunately for you, DGD makes sure only one copy of X is inherited in 
toto. If you need A and B to access different instances of X, then what 
you need is probably not inheritance. I suggest a LWO.

Zell



More information about the DGD mailing list