Just to throw something in:
How would you feel if my account object could withdraw the money from your
account object?

Knowing that some languages (java, C++,...) make the shortcut to do access
control at the class level for obvious speed reasons doesn't mean that
instance level would not make sense in some other languages (Eiffel) don't
you think?
In fact it was very surprising to me the first time I looked at C++ and
found that out. I believe that true encapsulation means instance level not
class level.

Jacques

"Regis Le Brettevillois" <[EMAIL PROTECTED]> wrote in message
akka5o$nhe$[EMAIL PROTECTED]">news:akka5o$nhe$[EMAIL PROTECTED]...
> I would add that's just the way a lot of languages work.
> Since you're in the same class, encapsulation doesn't make sense. Ideed,
> encapsulation allows programmer to hide the implementation to other
classes,
> since you're in the same implementation you can access all the object
> features.
>
> "Chris Bartley" <[EMAIL PROTECTED]> a �crit dans le message de news:
> akj6q1$rk2$[EMAIL PROTECTED]
> > Because private means private to a class, not an instance.  That's just
> the
> > way Java works.  See here for more:
> >
> > http://java.sun.com/docs/books/tutorial/java/javaOO/accesscontrol.html
> >
> > chris
> >
> > "Thomas Sundberg" <[EMAIL PROTECTED]> wrote in message
> > news:[EMAIL PROTECTED]...
> > > Hi!
> > >
> > > Could someone explain to me why this works? I has alway belived that
> > > private variables were just private to that particular instance, but I
> > > think this example shows that it is possible to reach the value of a
> > > private variable in another instance of the same class.
> > >
> > > Obviously I'm able to reach p2.name in the exmpale below from
> > p1.display().
> > > (I know beacues the class compiles and runs...)
> > > But I can't explain why at the moment.
> > >
> > > Anyone?
> > >
> > > public class Person {
> > >      private String name = null;
> > >
> > >      public Person(String namn) {
> > >          this.name = namn;
> > >      }
> > >
> > >      public void display(Person p) {
> > >          System.out.println(p.name);
> > >      }
> > >
> > >      public static void main(String[] args) {
> > >          Person p1 = new Person("Putte");
> > >          Person p2 = new Person("Quarolin");
> > >          p1.display(p2);
> > >      }
> > > }
> > >
> > > /Thomas
> > >
> >
> >
>
>


_______________________________________________
Eap-features mailing list
[EMAIL PROTECTED]
http://lists.jetbrains.com/mailman/listinfo/eap-features

Reply via email to