In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "C language and the introduction and function of derived class access attributes in C++", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn the introduction and function of the C language and the access properties of derived classes in C++.
Catalogue
Protect inheritance
Access properties of derived class members
Summary
Protect inheritance
Members declared by protected are called protected members, or protected members for short.
From the user's point of view, protected members are equivalent to private members. A protected member can be referenced by a member function of a derived class.
Access properties of derived class members
Four access attributes:
Common: in-class and out-of-class access
Protected: can be accessed within the class, not outside the class, and can be accessed by derived classes at the next level
Private: can be accessed within the class and not outside the class
Inaccessible: in-class and out-of-class access
Members in the base class access properties public inheritance (public) public members and protection members maintain the original access properties in the derived class public inheritance (public) private members are still private to the base class, derived classes are inaccessible private inheritance (private) public members and protected members are private members in the derived class private inheritance (private) private members are still private to the base class Derived class inaccessible protected inheritance (protected) public and protected members become protected members in a derived class protected inheritance (protected) private members are still private to the base class and derived classes are not accessible
Summary
If common inheritance is used in multi-level derivation, the common and protected members of the base class can be accessed until the last level of derived class.
If private inheritance is used, after several derivations, all members of the base class have become inaccessible
If you use vegetable inheritance, any member of the derived class cannot be accessed outside the derived class. And after many derivations, it is difficult for people to remember clearly which members can access and which members cannot, and it is easy to make mistakes.
Note: in actual development, we usually use public inheritance.
At this point, I believe you have a deeper understanding of the "C language and the introduction and role of access properties of derived classes in C++". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.