Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is it not against OO concept?

 
Geethakrishna Srihari
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The following code compiles:
class A
{
private int i;
public void modifyOther(A a1)
{
a1.i = 20;
}
}

The object has permission to use other object's private member ; it might be of same class - but is it not against OO? But this code compiles?
 
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
Encapsulation in Java is class-based, not object based. C++ is the same way. Some languages -- Ruby, and Python, I think, too -- have object-based encapsulation. I don't think one is more object-oriented than the other, really.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic