[DGD] Inheriting the same program twice
Petter Nyström
md1pette at mdstud.chalmers.se
Tue Apr 19 09:19:02 CEST 2005
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
More information about the DGD
mailing list