对引用变量的操作就是对原变量的操作


1 #include <stdio.h> 2 3 void change(int&x){ 4 x=1; 5 } 6 int main(){ 7 int x=10; 8 change(x); 9 printf("%d\n",x); 10 return 0; 11 }
注:以.cpp格式运行。
对引用变量的操作就是对原变量的操作
1 #include <stdio.h> 2 3 void change(int&x){ 4 x=1; 5 } 6 int main(){ 7 int x=10; 8 change(x); 9 printf("%d\n",x); 10 return 0; 11 }
注:以.cpp格式运行。
转载于:https://www.cnblogs.com/Catherinezhilin/p/11137843.html