In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article is to share with you about the relationship between inheritance and access qualifiers in C++. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
The relationship between inheritance mode and access qualifier
There are three ways of inheritance:
Public inheritance
Private inheritance
Protect inheritance
Relationship: if the member function of the base class is private, the derived class is invisible to the private members of the base class, and the other criteria are limited to the final access if the selection scope is small.
Protect member qualifier: some base class members do not want to be directly accessed by the object of the base class, but can only be accessed in a derived class, which is defined as a protected member. The protection member qualifier appears because of inheritance.
Understand concealment
Hiding means that the function of the derived class masks the base class function with the same name. The rules are as follows:
If the function of the derived class has the same name as the function of the base class, but the arguments are different, the function of the base class will be hidden with or without the virtual keyword.
If the function of the derived class has the same name as the function of the base class and the parameters are the same, but the function of the base class does not have the virtual keyword, the function of the base class is hidden.
Default member function of a derived class
If the six default member functions are not defined in the derived class, the compiler will default to the six member functions.
Constructor function
Copy constructor
Destructor function
Assignment operator overload
Address operator overload
Const modified address operator overload
# includeusing namespace std;class person {public: person (const char* name): _ name (name) {cout
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.