是参考变量C++的概念?它们在C中可用吗?如果在C中可用,为什么我的代码给出编译错误?
#include <stdio.h>
#include <stdlib.h>
int main()
{
int a = 10;
int b = 20;
int &c = a;
int &d = b;
return 0;
}
输出:
bash-3.2$ gcc test.c
test.c: In function `main':
test.c:12: error: parse error before '&' token
为什么?
您可以通过在每行的前面放置四个空格来将代码格式化为代码。 (我已经在这里为你完成了。) – 2010-01-13 14:57:54
这里是答案:http://stackoverflow.com/questions/1825794/passing-pointer-argument-by-reference-under-c/1825813#1825813 – 2010-01-13 15:06:04