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
has been the concept of these modifiers is not very clear, while the intern assessment just ended empty time to study.1. Modifiers that can modify member variables and member methods have three plus one default. Their scope uses the following:Scope
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
Let me simply draw a table to illustrate the problem:
modifiers
Scope (visible)
Current class
Same package
Descendant class
Other Packages
Public
√
√
√
√
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
Reference Code#include #include using namespace std;class father { int id;protected:int tt;public: Father (): ID (3) {}void print () {printf ("This was Father public function%d\n", id);} void Changeid () {id=10;printf ("Change the value of ID to 1
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
First, ThreadJava/c++ is an object-oriented third-generation computer high-level programming language, its essence is identical, but the syntax is really different, a little attention is easy to cause confusion. This article summarizes some of the
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
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
Original article link
Summary of public, protected, and private access labels in C ++
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. Its
Public: open to any class and member, unrestricted access;Protected: Only the class and derived classes of that class are exposed;Private: Only open to the class;Internal: The class can only be accessed in assemblies that contain the class (only
Java provides three access control permissions: Public protected private. Therefore, the access permission with the name "anonymous" means that external users cannot access the database. When inheriting the database, you must consider whether the
A member of the class can be: private protected public1. If a member is private, its name can only be used by the member functions and Friends of the class in which it is declared2. If a member is protected, its name can only be used by the member
/* Function, C ++ public, protected, private date, March 13, 2013 environment, ubuntu1204-gcc blog, login Using STD: cout; Using STD: Endl; template void OK (t) {} Class A {// public can be accessed anywhere in the program, you do not need to use
University career, involving the scope of the class, inheritance are used by the public common inheritance, at that time did not think so much, feel the common inheritance more convenient, how simple, anyway, there is no too many restrictions,
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.