c语言 什么时候要传入参数的引用“&” —— 对参数的修改结果需要“带回来

实例:

#include <stdio.h>
void test(int x)
{
  
   x= 2020;
   printf("test内部 x=%d
",x);
}
int main()
{
   int  x = 1024;
   test(x);
   printf("test调用后x=%d
",x);
}

实例:

#include <iostream>
using namespace std;
#include <stdio.h>
void test ( int & x )
{
  
   x= 2020;
   printf("test内部 x=%d
",x);
}
int main()
{
   int  x = 1024;
   test(x);
   printf("test调用后x=%d
",x);
}

这里看出来  & 传入 可以 改变 值 

原文地址:https://www.cnblogs.com/guangzhou11/p/14241222.html