In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "how to quote C++ better". In daily operation, I believe many people have doubts about how to quote C++ better. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the questions of "how to quote C++ better". Next, please follow the editor to study!
[example 1]: int a; int & ra=a; / / definition reference ra, which is a C++ reference to variable a, that is, an alias
(1) & here is not to find the address operation, but to identify the role.
(2) Type identifier refers to the type of target variable.
(3) when declaring a reference, it must be initialized at the same time.
(4) after the reference declaration is completed, there are two names for the target variable name, namely, the target original name and the reference name, and the reference name can no longer be used as an alias for other variable names.
Ra=1; is equivalent to axi1.
(5) declare a reference, not a new definition of a variable, it only means that the reference name is an alias of the target variable name, it is not a data type, so the reference itself does not occupy the storage unit, and the system does not allocate the storage unit to the reference. Therefore: to find the address of the reference is to find the address of the target variable. & ra is equal to & a.
(6) A reference to an array cannot be created. Because an array is a collection of several elements, an alias for an array cannot be created.
Citation application
[example 2]:
Void swap (int & p1, int & p2) / / the formal parameters p1 and p2 of the function here are references {int p1; p1roomp1; p1roomp2; pp2=p;}.
In order to call the function in the program, the corresponding call point of the main tone function can be called directly with the variable as the argument without any special requirements of the argument variable. For example, corresponding to the swap function defined above, the corresponding tone function can be written as follows:
Main () {int a _ r b; cin > > a > b; / enter the value of swap (a _ r b); / / call the swap function cout directly with variables an and b as arguments
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.