<分区>
Possible Duplicate:
What are the differences between pointer variable and reference variable in C++?
Pointer vs. Reference
要在 C++ 中执行按引用调用,我想我可以使用这两个中的任何一个:
int f(int *x);
int g(int &x);
他们会这样称呼:
int *w;
f(w);
g(*w);
int y;
f(&y);
g(y);
函数 f
和 g
有区别吗?我应该能够在两个函数中将 x
作为 int*
指针和 *x
作为 int
来使用.那有什么区别呢?