1. Common four azimuth modifier relationshipsThe protected internal is a relationship of the association, meaning that it is internal within the namespace and is protected outside the namespace.
2.sealed FinalThe sealed modifier can be applied to
In PHP, the access control of the property or method is implemented in front of the public private protected and other keywords, public decorated class members can be accessed anywhere, private decorated class members can only be accessed by
About the protection of methods and properties inherited from base classes:--class pig:public Animal {...}C + + Not only allows you to enforce access control over the methods and properties defined in the class, but also allows you to control which
Public is the most accessible, such as name, everyone can know someone else's name, this is not a secretProtected has lower access rights, only subclasses can access the protected property of the parent class. It's like Lao Tzu's property is
Java supports four different kinds of access rights:
modifier
Description
Public
Common, visible to all classes.
Protected
Protected, visible to classes and all subclasses within the same
Encapsulation is one of the three characteristics of surface object programming, encapsulation is to combine the properties and services of an object into a separate unit, and to conceal the inner details of the object as much as possible, including
Analyze the public, protected, private, and default access permissions of java from the perspective of instances, publicprotected
1. public
Same package
1. Internal
Public class A {public int f = 1; public void m1 () {} public void m2 () {f = 2;
The private member of the base class is not visible after it is inherited (highest priority)
Public inheritance does not change base class member properties
Protect inheritance (private inheritance) change a base class member to a protected
The difference between public, protected and private
Draw conclusions from Classname::functionnmae (), instantiation, parent, self
Classname::functionnmae () requires a static method (public mode)
Parent::functionnmae () parent class needs to be
PHP public, protected, private three types of access control mode differences
Public: Common Type在子类中可以通过self::var调用public方法或属性,parent::method调用父类方法在实例中可以能过$obj->var 来调用 public类型的方法或属性
Protected: Protected
http://teddyboy200382.blog.163.com/blog/static/320112002008825112549780/Description of these four keywords before I want to justClassTo make a simple definition of the relationship, for the inheritance of their ownClass,Base classcan be thought of
Three kinds of access rights
Public : can be accessed by any entity
protected: only child classes and member functions of this class are allowed to access
Private: only member functions of this class are allowed to access
Three ways of
Summarize:1. The difference between protected and private is that the access designator limit of the protected can be accessed by the member functions of the derived class, and private cannot2. The difference between protected and publice is that
In a place to see a picture, a simple and clear explanation of the relationship between the three, it is very admirable, then recorded.//public inherited object access member access Public- Publicy yprotected-protectedN YPrivate-PrivateN N//securing
reference:http://www.studytonight.com/java/modifier-in-java.phpModifiers is keywords that is added to the change meaning of a definition. In Java, Modfiers is cateogrized into and types:1. Access Control modifier2. Non Access modifier1) Access
First:Private, Public,protectedthe access scope of the access designator. Private: only by 1. Functions in this class,2. Its friend function access. The object of the class cannot be accessed by any other access. protected: can be 1. Functions in
Access modifier: used to describe the access modifier where a member (attribute, method) can be accessed:
Used to describe where a member (attribute, method) can be accessed!
Tip:PHP adopts the concept of class to restrict access to members!PHP
Class
{
Public:
Int;
PRIVATE:
Int B;
Protected:
Int C;
};
// // public inheritance: //-data access type not change //-B cannot access a's private member /// Class B: public a { Public: void test () { A = 1; /B = 1; // fail C = 1;
Java modifier types (public, protected, Private, friendly)
Public classes, class variables and methods, any class in and out of the package can be accessed;Protected classes, class variables and methods, any classes in the package, and those
Three Access Permissions
Public: can be accessed by any entity
Protected: only access to child classes and member functions of this class is allowed.
PRIVATE: only access to member functions of this class is allowed.
Three inheritance
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.