This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Private methods

 
Brian, Cavanagh
Ranch Hand
Posts: 70
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can they be overridden???
 
Brian, Cavanagh
Ranch Hand
Posts: 70
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right, so despite the fact that it looks like an override, it is not. Is that what you are saying?
 
Adrian Yan
Ranch Hand
Posts: 688
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What? Private method is not inherited? Are you sure?
 
Aru Ven
Ranch Hand
Posts: 199
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sam,
I think PRIVATE methods are not inherited. ANd can't be OVERRIDDEN coz they belong only to the class that declares them & not to the class that extends them.
Aruna
 
Sam Wong
Ranch Hand
Posts: 133
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ack! I think I got it now. Private members and all constructors are not inherited by subclasses. How does this affect overriding? I'm not sure. I'm back to my original statements. Funny how RHE implies that private members are inherited. p.79 and p.83. It states that private methods can be overridden by private, default, protected or public methods. So if a private method is not inherited, does defining the exact same method be considered overriding? I guess so. Overriding is basically redefining the method. I suppose this is true whether the overridden method is private or otherwise. So I guess the answer to the question is yes.
[This message has been edited by Sam Wong (edited December 14, 2000).]
 
Sam Wong
Ranch Hand
Posts: 133
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for clearing things up, everyone. Good topic. Got me all confused.
 
Rajiv Ranjan
Ranch Hand
Posts: 61
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Private methods are not inherited and also cannot be overridden.
If you declare a method with the same name as the private method in any subclass it is entirely a new method.
Rajiv
 
Sam Wong
Ranch Hand
Posts: 133
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, now its all clear. Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic