#include
int find(int *a);
main()
{
int b = 1;
int wait, test;
test = find(&b);
printf("内存地址为:%d",&test);
scanf("%d", &wait);
}
int find(int *a)
{
return *a;
}
int b = 1; int test = find(&b); 这样调用时,实际上是进行了:int* a = &b,创建了一个新的指向b的整型指针a作为find函数范围内的局部变量。
函数声明:int find(int& a); 函数调用:int b = 1; int n = find(b);
这样调用时,实际上是进行了:int& a = b,给变量b起了个别名a,也就是说a和b实际上代表的是同一个变量,调用期间没有创建任何新的变量。
函数声明:int find(int a); 函数调用:int b = 1; int n = find(b);
这样调用时,实际上是进行了:int a = b,也就是普通的变量赋值操作,调用期间创建了在find函数范围内的局部变量a,它的值与b相同。