In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "what does in-out in C++ mean?" in the operation of practical cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Translator's note: in-out refers to the parameters that transfer input information to a function and obtain output information at the same time.
Reason (reason)
This makes it clear to callers that the object is assumed to be modified.
Make it clear to the caller that the object may be modified.
Example (sample)
Void update (Record& r); / / assume that update writes to rNote (note)
The T & type parameter can pass information to or get information from the function. Therefore, T & can be used as an input / output parameter. (but if used improperly,) it may be a problem in itself and the cause of the error.
Void f (string& s) {s = "New York"; / / non-obvious error}
Void g () {string buffer = ".."; f (buffer); / /...}
The writer of the function g () in the code provides f () with a buffer to populate, but f () simply replaces it (which is slightly more expensive than a simple string copy). If the writer of g () incorrectly assumes the size of the buffer, it can lead to very bad errors.
Enforcement (implementation recommendations)
(Moderate) (Foundation) Warn about functions regarding reference to non-const parameters that do not write to them.
(medium) ((basic criterion)) when a function treats a reference as a non-constant parameter but does not write them, an alarm is given.
Translator's note: if it is only used to enter information, you should use the value passed or the const type.
(Simple) (Foundation) Warn when a non-const parameter being passed by reference is moved.
(simple) ((basic criteria)) alarm when a non-constant parameter passed by reference is moved.
Translator's note: the non-constant parameter means that it will also be used to output information and cannot be used if the content is moved.
This is the end of the content of "what does in-out in C++ mean?" thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.