我可以通过引用传递任何参数,并且在任何函数调用中对该变量的更改也将反映在其他函数调用中。
同样,如果我想使存储在指针中的地址在所有函数调用中保持一致,以使其表现得像我们通过引用传递指针一样。
#include <iostream>
void f(int * & p) {
std::cout << p << std::endl;
}
int main() {
int x;
int * p = &x;
std::cout << p << std::endl; // This prints the same...
f(p); // ... as this.
}