• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Rules round up question doubt

 
Siri Naray
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can one object access the private variable of another object of the same class?

Private means private to the class not object. So 2 objects of teh same class can access each other private data.

My doubt is.. how can an obj access another objects data first place?
What does this statement mean?? If teh answer is right can anyoen give an example code for this??
Sorry if its a primitive question.
Thank you sirisha
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you call the method "m" of class "C", you have to supply another instance of "C" as the argument. "m" takes the value of "i" from the other instance of "C", and sets its own variable "i" to that value plus one.

 
Siri Naray
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic