In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "what is the use of C++ definition operator", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "what is the use of the C++ definition operator?"
Operators are defined mainly to imitate idioms
Reason (reason)
Minimize surprises.
Make the program look more natural.
Example (sample)
Class X {
Public:
/ /...
X & operator= (const X &); / / member function defining assignment
Friend bool operator== (const const, const X &); / / = = needs access to representation
/ / after a = b we have a = = b
/ /...
}
Here, the conventional semantics is maintained: Copies compare equal.
Here, the customary semantics of assignment and equality comparison are maintained.
Example, bad (negative example)
X operator+ (X a, X b) {return a.v-b.v;} / / bad: makes + subtractNote (note)
Nonmember operators should be either friends or defined in the same namespace as their operands. Binary operators should treat their operands equivalently.
The non-member operator should be either a friend function or defined with an Operand. Binary operators should treat operands equally.
At this point, I believe you have a better understanding of "what is the use of the C++ definition operator?" 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: 234
*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.