C++函数中"通过引用传递"和"通过指针/地址传递"有什么区别?

use*_*165 -1 c++ pointers function

功能原型:

1. int test (int & i);
2. int test (int * i);
Run Code Online (Sandbox Code Playgroud)

函数调用:

1. test(n);
2. test(&n);
Run Code Online (Sandbox Code Playgroud)

任何人都可以解释尽可能多的方面的差异吗?非常感谢!

Yuu*_*shi 5

引用不能是NULL指针可以.这基本上是唯一的区别.一般来说,它是一个实现细节,所以从理论上讲,通过引用传递并通过指针传递可能在"引擎盖下"不同,但是,它们几乎总是以相同的方式实现.