[GR-Jug] inheritance ?

Derek Vredevoogd Derek.Vredevoogd at requestfoods.com
Mon Feb 2 18:02:12 EST 2004



Matt.

Thank you very much for your input.
It seems that you have a very good idea of what I am asking.
I was not really suggesting doing some kind of reverse inheritance up the
tree.
Only using polymorphism, like Carlus explained.
Interesting idea about casting a parent to its child, but I too can't think
of a
reason to do that.
I don't know why you suggest protected, verses another form of a access
modifier,
but I don't feel that including this feature in all of the children would be
beneficial
nor do I want to adopt it under a different parent which would loose my
polymorphic utility.
The feature I am interesting in is particular to one child and one child
only.  
It would be private so that this child would be the only one that accesses
it.  Nevertheless, I don't think it would be copied over to its parent.

But, I still have my original question concerning if modifiers affect
inheritance.


Derek.

-----Original Message-----
From: Matthew Carpenter [mailto:matt at eisgr.com]
Sent: Monday, February 02, 2004 2:53 PM
To: Grand Rapids Java Users Group Mailing List
Subject: Re: [GR-Jug] inheritance ?


You are a member of the Grand Rapids Java Users Group mailing list.  
Please see the bottom of this message for information on
unsubscription/customizing your preferences.
Derek Vredevoogd wrote:

>You are a member of the Grand Rapids Java Users Group mailing list.  
>Please see the bottom of this message for information on
unsubscription/customizing your preferences.
>Hey thanks.
>I don't know if I quite understand you're logic here.
>But, I do have an idea what you are saying.
>I can ask again at the next meeting.
>
>I was dealing a bit with polymorphism.  
>I was hoping to put a private method in my 
>subclass and have it still be available in 
>its parent class(without declaring it in the parent) after conversion.  But

>somehow I don't think that will work.
>But, then I got real confused and this 
>question came to mind.
>Anyways, no worries. Not a big deal right now.
>
>------
>
>OK, here is a stumper, at least for me.
>
>Do the modifiers assigned to features in a parent class 
>dictate what features will be inherited by its children?
>If so, what are the rules, and where is a good document about it?
>
>Modifiers:
>public,default,protected,default
>final,abstract,static,native,transient,
>synchronized,volatile
>
>features:
>class, method, or variable
>
>  
>
There is not way to inherit up the inheritance tree.  Inheritance only 
flows "down" from parent to child.  If you are a hack, you can cast the 
parent object as its child in order to take advantage of the child's 
methods, but why not just implement the method in the parent as a 
"protected"?  If it doesn't work for all children, reimplement over it, 
or re-subclass (adopt) it under a different parent.

Make sense?  To reiterate Carlus's question, what exactly are you trying 
to do?  Why would it make sense to NOT implement in the parent and yet 
use it there?

_______________________________________________
Jug mailing list
Jug at gr-jug.org
Un/Subscribe/Customize http://gr-jug.org/mailman/listinfo/jug



DISCLAIMER: The information in this message is confidential and may be
legally privileged. It is intended solely for the addressee.  Access to this
message by anyone else is unauthorized.  If you are not the intended
recipient, any disclosure, copying, or distribution of the message, or any
action or omission taken by you in reliance on it, is prohibited and may be
unlawful.  Please immediately contact the sender if you have received this
message in error. Thank you.




More information about the Jug mailing list