In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "how to apply C++ friends and operator overloading". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought. Let's study and learn how C++ friends and operators overload.
Friendly yuan
In life, your home has a living room (Public) and your bedroom (Private). All guests in the living room can enter, but your bedroom is private, that is to say, only you can enter, but you can also allow your best friend and gay friend to enter.
In the program, some private properties also want to be accessed by some special functions or classes outside the class, so they need to use friend technology.
The purpose of friends is to allow one function or class to access private members of another class.
The keyword of friend is: friend
There are three implementations of friends:
Global function as friend
Class as friend
Member functions as friends
1 the global function friend class Building {/ / tells the compiler that the global function is a good friend of the Building class and can access the private content friend void goodGay (Building * building) in the class; public: Building () {this- > m_SittingRoom = "living room"; this- > m_BedRoom = "bedroom";} public: string m_SittingRoom / / living room private: string masked BedRoom; / / bedroom}; void goodGay (Building * building) {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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.