[DGD] Inheriting the same program twice

Petter Nyström md1pette at mdstud.chalmers.se
Tue Apr 19 09:36:02 CEST 2005


> 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.

Maybe I am not making sense.

Jimorie

> On 4/19/05, Petter Nyström <md1pette at mdstud.chalmers.se> wrote:
>> I have run into a situation where it would make sense to have an object
>> inherit a program twice, at different points in the inheritance tree.
>>
>> With some ascii-graphic my inheritance tree would look like:
>>
>>            A
>>           / \
>>          B   X
>>         / \
>>        X  ...
>>
>> (Or in words: A inherits B and X, B inherits X.)
>>
>> I am somehow led to believe this is very bad design, because as my code
>> looks right now this shouldn't even compile. That is because I haven't
>> defined any of the functions in X in A, so calls to these function in
>> objects of type A should be ambiguos, but they are not and it does
>> compile. This hints that maybe it doesn't matter if you inherit the same
>> program multiple times in one object, it will still only have one data
>> space for that program?
>>
>> I would be happy if someone could tell me some truths on this subject. And
>> perhaps also suggest good design alternatives to my problem here. It do
>> makes sense for me to have objects of type A to have duplicated and
>> separable data fields as defined by X.
>>
>> Jimorie
>> __________________________________________
>> http://mail.dworkin.nl/mailman/listinfo/dgd
>>
>
> __________________________________________
> http://mail.dworkin.nl/mailman/listinfo/dgd
>



More information about the DGD mailing list