What are the references passed in C++?
This article mainly explains "what are the citation transmission in C++". The content of the explanation in the article is simple and clear, and it is easy to learn and understand. Now please follow the editor's train of thought slowly and deeply. Let's study and learn what are the citation transmission in C++!
Citation delivery in C++
In C++, parameter passing includes value passing, and its usage is the same as in C language, but reference passing, as a major feature of C++, is not supported in C language.
1. Creation of reference variables: int rats;// creates reference variables rodents as aliases for rats int & rodents = rats; considerations for using reference variables:
Initialize when declared
Once associated with a variable, allegiance is only to that variable
For the first article above:
The disallowed use of int rats;// int & rodents;rodents = rats
For the second article, you can refer to the following example:
# include
< iostream >Using namespace std;int main (void) {int rats = 10; int & rodents = rats; int bunnies = 20; cout