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
After learning Java for two years, I suddenly found myself confused about the basic concepts of public, friendly, private, and protected, so I opened thinking in Java se...
Summary:
Public:The data member and member Methods declared as public
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
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√√√√
PrivatePrivate functions can only be called in the context of the class and subclass, and can only be accessed through self.This means that the private function can only be accessed within the object.The access permission of the object instance
This is the record on the document.The Scope of Instance VariablesTo enforce the ability of a object to hide it data, the compiler limits the scope of instance variables-that is, limits Their visibility within the program.To force an object to hide
To enforce the ability of a object to hide it data, the compiler limits the scope of instance variables-that is, limits Their visibility within the program.To force an object to hide its data, the compiler restricts the scope of the instance
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 # include 2 # include 3 # include 4 # include 5 # include 6 # include 7 # include 8 # include 9 # include 10 # include 11 using namespace STD; 12 13 14 Class A {15 private: 16 int aprivatevar; 17 void apirvate () 18 {19 cout
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.
Private, Only the class can be accessed directly,Protected, which can be accessed directly within the class and subclass,Public, which can be accessed directly by anyone.The inheritance type indicates the parent class.Example:Class {Public:Int
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
When private, public, and protected are set as members of a class:PRIVATE: It can only be accessed by functions in the class and their meta-functions. It cannot be accessed by any other function, nor can it be accessed by objects in the
First, the access range of the private, public, and protected access labels.
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
Normal 0 7.8 磅 0 2 false false false MicrosoftInternetExplorer4
Some people often ask during interviews:C ++How can I fail?PublicFunction to obtainPrivate?
Of course, there are many
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 ()
1.private modifier
The private modifier is used to set the access rights of a class or class member to the internal of the owning class only.Private is also known as a proprietary modifier. When you need to access a private class member at some
(1) for the public modifier, it has the largest access and can access any one of the classes, interfaces, exceptions, and so on under Classpath. It is often used for external situations, i.e. the form of an interface to an object or class.
(2) for
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.