J
Jacob Weber
Hello. I'm having a little problem understanding one aspect of
inheritance. It's a little hard to explain, but I think it must be a
common problem.
I have two base classes, each with the same number of subclasses:
A B
/ \ / \
A1 A2 B1 B2
I need A1 to contain a field with type B1, and likewise A2 should
contain a field of type B2.
Now, since B1 and B2 share common methods (from B), I would like to be
able to call those methods from A. Even though A doesn't know the
specific type of the field, it knows it's an instance of B, right?
Is there a way to make this work?
Jacob
inheritance. It's a little hard to explain, but I think it must be a
common problem.
I have two base classes, each with the same number of subclasses:
A B
/ \ / \
A1 A2 B1 B2
I need A1 to contain a field with type B1, and likewise A2 should
contain a field of type B2.
Now, since B1 and B2 share common methods (from B), I would like to be
able to call those methods from A. Even though A doesn't know the
specific type of the field, it knows it's an instance of B, right?
Is there a way to make this work?
Jacob