In the C # language, there are five types of access modifiers: public, private, protected, internal, protected internal. public access. Not subject to any restrictions. Private access. This class is restricted to access by members, subclasses, and
Abstract: This article is a reflection on the previous post of bbs c/C ++. When I saw the post, I suddenly felt that I had timed out. It seems that I am getting unfamiliar here. This article attempts to discuss how the access control operator works,
Beginners PHP, see other people's packaging class has these three attributes, so look up the relevant data summarized the difference between the following:Can be called by Self::var or Self::method in a subclass, you can invoke a method in the
Keywords commonly used in PHPThere are a lot of keywords in PHP that restrict functions and classes, often abstract,final,interface,public,protected,private,static, and so on, and we'll analyze them for each usage.keywords for variables and methods
Before explaining the Four keywords, I want to make a simple definition of the relationship between classes. For a class that inherits its own, the base class can think that they are all their children, classes in the same directory as yourself are
1. Access scope of the private, public, and protected methods.
* Private: It can only be accessed by methods in the class and cannot be accessed by objects in the class.
* Protected: it can be accessed by methods in the class and their friends
This article is to introduce the difference between the three of them in PhP5, the three of them are used in the class, but the properties are completely different.
Public: Common property or method
Can be called by Self::var or Self::method in a
Document directory
1. Public:
2. Private:
3. protected:
4. Internal:
5. Protected internal:
To control the access permissions of objects in C #, you can add modifiers before defining objects.
There are five modifiers: private, protected,
Public: Common property or method
Can be called by Self::var or Self::method in a subclass, you can invoke a method in the parent class by Parent::method, but you cannot call the public property.
You can invoke the $obj->var or Self::method in the
Turn: http://www.cnblogs.com/burandanxin/archive/2009/12/17/1626734.html
Before explaining the Four keywords, I want to make a simple definition of the relationship between classes. For a class that inherits its own, the base class can think
There are three types of access modifiers in PHP, namely:Public (common, default)
Protected (Protected)
Private (privately)
Public (common, default) in PHP5 if the class does not have an access modifier for the specified member, the default is the
Before explaining the Four keywords, I want Class Make a simple definition of the relationship between them. Class , Base Class It can be thought that they are all their children, and Classes And think they are all friends of their own.
The visible ranges of these four scopes are shown in the following table.
Note: Friendly is indicated if no access modifiers are written above the decorated element.
Scope Current class same package descendant class other package
Public√√√√
Scope current similar Bun class otherPublic√√√√Protected√√√xDefault √√xxPrivate√xxxDefaults to default when members of a class do not write access adornments. The default is equivalent to exposing (public) to other classes in the same package, and
Description of the meanings of the access modifiers public, private, protecte, and default in Java:Public (interface access permission): modifier with the widest access restriction in Java, which is generally called "public ". Classes, attributes,
1: private, public, protected member functions
PRIVATE: It can only be accessed by 1. functions in this class, 2. Other functions.Cannot be accessed by any other user, nor can the object of this class be accessed.
Protected: it can be accessed by 1.
Before explaining the Four keywords, I want to make a simple definition of the relationship between classes. For a class that inherits its own, the base class can think that they are all their children, classes in the same directory as yourself are
PHP has three access modifiers:Public (public, default)Protected (protected)Private)Public (public, default) in PHP5, if the class does not have an access modifier for the specified member, the default access permission is public.Protected
1. Private Modifier The private modifier is used to set the access permission of a class or class member to the internal of the class,Private is also called a private modifier. You can use the get and set accessors to read or modify private class
Class Parent { Public: parent (INT Var =-1) { m_npub = var; m_nptd = var; m_nprt = var; } Public: int m_npub; protected: int m_nptd; PRIVATE: int m_nprt; }; // public inheritance class Child1: Public parent { Public: int getpub ()
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.