Adding a superclass reference for subclass objects

Forums for specific tips, techniques and example code
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Adding a superclass reference for subclass objects

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:54 pm

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!

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Adding a superclass reference for subclass objects

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:54 pm

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.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Adding a superclass reference for subclass objects

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:54 pm

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!


Return to “Tips and Techniques”

Who is online

Users browsing this forum: No registered users and 10 guests