1. We often encounter delivery problems and modify the function of the shape involved in arguments at the time of writing C ++ language program, then if we want to pass parameters to modify the function parameters in the main function also corresponds to the same changes, we can add in the parameter address-identifier can be a function of, if the parameters do not want to pass parameters to the function main function also follow the changes we do not add character to take the address
2. The following is a specific test code:
7 output the first code, the second code output 5
#include<iostream>
using namespace std;
void test(int &head){
head += 2;
}
int main(void){
int head = 5;
test(head);
cout << head << endl;
return 0;
}
#include<iostream>
using namespace std;
void test(int head){
head += 2;
}
int main(void){
int head = 5;
test(head);
cout << head << endl;
return 0;
}