Описание тега access-specifier
The access specifier in an object-oriented language determines how a class restricts access to its members.
The access specifier in an object-oriented language determines how a class restricts access to its members.
The usual access specifiers are private
, protected
and public
.
- A class member whose access specifier is
private
can only be used by instances of that class. - A class member whose access specifier is
protected
can only be used by some other classes.
Usually this means that access to these members is granted only to subclasses, but this is not a hard-and-fast rule. In Java, for example, classes that are in the same package also have access to each other'sprotected
members. - A class member whose access specifier is
public
can be used by all other classes in the program.
You can use this tag for questions about how access to the members of your class is resolved.