Friday, October 25, 2013

Public / Private / Protected

Public / Private / Protected

In classes, we attach what is called a visibility to our objects and our methods.
We always have three choices when assigning: public, protected or private. Public
means the class's objects and methods can be accessed by calls from anywhere.
Protected means the objects and methods can only be accessed by methods and
calls which are in the same class tree as the method or object being called. Private
means the methods and objects can only be accessed by the class that the method
or object belongs to.

No comments:

Post a Comment