Get the App
SLTechnology News&Howtos  ›  Network Security  › 

Access type control (public, private, protected)

Shulou Source: shulou.com Published: 2022-06-01 07:02:39 10月03日 Update

Access control modifiers include public (public, default), private (private), and protected (protected).

1.public

Members of the class have no access restrictions, and all external members can access the members of the class.

2.private

There are no access restrictions for all members of the same class, but external code of the class is not allowed to change or even operate, and for subclasses of the class, there is no access to private-decorated members.

3.protected

It has access to subclasses of this class and subclasses of subclasses, and can read and write properties and methods. However, it cannot be accessed by the external code of the class, nor does the external code of the subclass have access to its properties and methods.

Tags: Subclasses members code properties methods permissions restrictions controls protection private types Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux MariaDB NVidia Shulou Information macOS