Access permission for C ++ protected members
The discussion on the access permissions of protected in C ++ is already a very old topic, and it is so old that everyone is reluctant to discuss it.
When I read c ++ primer again, the description of
Protected, like public and private, is used to declare the access rights of a member. The members declared by protected are called "protected members", or "protected members" for the short term. From the user's point of view of the class, the
Access permission for C ++ protected membersThe discussion on the access permissions of protected in C ++ is already a very old topic, and it is so old that everyone is reluctant to discuss it.When I read C ++ Primer again, the description of the
In fact, the common class is the object template. To enhance js oo features, we can use a JSON object to describe this object template inspired by the mootoos framework. In this template, we can simulate Private Members, protected members, and
We know that in C #, inheritance allows a base class with common data and methods to be widely used to reduce the amount of code, so that derived classes have all members of the base class (except constructors, etc.), and we can naturally use the
In fact, the common class is the object template. To enhance js oo features, we can use a JSON object to describe this object template inspired by the mootoos framework. In this template, we can simulate Private Members, protected members, and
protected and private in pyThonIn Python_var; The variable name is defined by an underscore, which is a protected member protected that only the class and its subclasses can access. This variable cannot be imported through the From XXX import
A friend of mine asked me a few days ago why the parent class cannot be accessed in the subclass.ProtectedMethod?
What she saw in a bookCodeProbably as follows:
Public Class A
{
Public StringName ="";
Protected IntAge = 0;
}
Public
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->
Using
System;
Using
System. Collections. Generic;
Using
System. LINQ;
Using
System. text;
Using
Nunit. Framework;
Using
System.
When a derived class is publicly inherited from a base class, the member functions of the derived class can directly access the public members of the base class, but they cannot access the private members of the base class. Therefore, in order to
Comparison of access permissions in public, protected, and private in C ++:
Public-defined members can be accessed anywhere;
Members defined by protected can only be accessed in the class and its subclass;
Private-defined members can only be
Inheritance ( refers to the mechanism of sharing properties and operations between classes)Virtual base class is inherited by adding the keyword virtual to avoid ambiguity.{Self-Understanding:Public: The public and protected members of the base
Reprinted from HTTPS://WWW.CNBLOGS.COM/33DEBUG/P/6666939.HTML1, inheritance and derivationInheritance is an important means to make code reusable, and it is also one of the core ideas of object-oriented programming. Simply put, inheritance refers to
First, the article for the reasonSimple and clear reasons, commonplace but not really solve the problem, want to understand this problem.Ii. a lengthy definitionLet's take a look at these lengthy definitions:Public inheritance:
When a class
Three inheritance methods in class design and three inheritance methods are designed.Zookeeper
By inheritance, a new class can be derived from an existing class, and the derived class inherits the features of the base class, including methods. Just
Inheritance is an important means to make code reusable, and it is also one of the core ideas of object-oriented programming. Simply put, inheritance refers to the properties and methods of an object using another object directly. Inheritance
Public, private, and protected are common inheritance methods.
1. Public inheritance)
Public inheritance is characterized by the original state of both the public members of the base class and the protected members as the members of the derived
Reprinted, relieved to read C + + Primer mind puzzled: http://www.cnblogs.com/harlentan/archive/2011/03/05/2006444.htmlAbout the access rights of protected in C + + is a very old topic, old to everyone is reluctant to discuss, think he saw to eat to
1. Three types of class members
Public members can be accessed by any class,
Protected members are limited to themselves and subclass access. Used in the same class, whose access rights are equivalent to a private member, but when derived, his
About the access rights of protected in C + + is a very old topic, old to everyone is reluctant to discuss, think he saw to eat to sleep so natural.When I read "C + + Primer" again, the description of protected members is this:Protected membersThe
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.