In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article shows you how to quote qualified member functions in Craft 11. The content is concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
Tracer projectiles
The code will vary depending on your needs.
The code not only implements the constructor and destructor, but also
Two methods of setText and output are implemented to modify and output content.
The + = operator and + operator are overloaded for object connection
Reference code
As a groundwork for the rest, consider the following code:
A series of instances of T1 and T2 are generated in the code, and then the two are added and output. It is worth noting that the result of t1+t2 is not passed to another object but calls the output method directly. The output can refer to the following figure, mainly focusing on the part between "=".
First, a temporary object is created, and the output is destroyed immediately. This object is a right value, and you can get the correct output by calling the object method on the right value. If our goal is to output the results, there will be no problem.
In the above example, the output method is called on a right value, which seems natural, but calling other functions is not necessarily so natural. For example, the following code calls the setText method on the result of t1+t2:
The output is as follows:
Although the setText method is called normally, the object is immediately destroyed and cannot be accessed. In other words, this is an invalid code. I believe this is not the original intention of the programmer.
Reference qualifier (reference qualifier)
The goal is simple: you want to impose a restriction that the right-value object cannot call the setText method. The method is just as simple, as long as you add a "&" to the method signature to tell the compiler that this function is only valid for the left value (reference). It looks like this:
After the reference qualification is added, the following code generates a compilation error.
The above is how to refer to qualified member functions in Category 11. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
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.