Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Protected and Private

 
Conrad Kirby
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the difference between protected and private? Can you read the values of a protected class variable, but not write to it? Or am i completely off track.
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Conrad,
Protected: Can be seen (and used) by the class and any subclasses.
Private: Can only be seen by the class.
The accessor modifiers apply the restrictions to reading and writing. Either you see it and can do anything or you don't and can't!
Regards,
Manfred.
 
Conrad Kirby
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well thankee kindly! I'll just mosey on back to work!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic