Page 1 of 1

Adding a superclass reference for subclass objects

Posted: Fri Aug 07, 2009 2:54 pm
by ConvertFromOldNGs
by Brian Lucas >> Wed, 30 Nov 2005 1:36:07 GMT

I am trying to add an implicit reference to a class that may reference one of several subclasses of an abstract superclass.

For example:
A =superclass (abstract)
B,C,D = subclasses (real)
E = referencing class (real)

What I want to do is add a reference, say "myA", to class E, where the actual object referenced may be of subclass B, C, or D. If I make the reference point to class A, the model doesn't show the sub-class relationship. Will I still be able to set the references to B, C & D at run-time even though the referenced class is A?

If there's another way to go about this, I'd like to hear that, too. Thanks!

Re: Adding a superclass reference for subclass objects

Posted: Fri Aug 07, 2009 2:54 pm
by ConvertFromOldNGs
by dcooper@jade.co.nz >> Wed, 30 Nov 2005 5:22:37 GMT

Yes, you will. If you add a reference E::myA of class A, you will be able to assign to it references of instances of B, C and D.

Dean.

Re: Adding a superclass reference for subclass objects

Posted: Fri Aug 07, 2009 2:54 pm
by ConvertFromOldNGs
by Brian >> Thu, 1 Dec 2005 0:20:41 GMT

Great, thank you! I was hoping this was true but couldn't find it anywhere in the documentation. This makes my class modeling much easier.

Thanks for the quick response, too!