GCC下引用类型解决思路

GCC下引用类型
我在VS2005里编写一个程序,现在要转移到Linux的GCC编译。我在VS2005用到了很多引用,但当我用GCC编译的时候却提示错误,示例和错误提示如下:
——————–源程序—————
#include<stdio.h>
int main()
{
  int a = 10;
  int&x = a;
  printf("Value is %d\n",x);

  return 0;
}
——————-错误提示—————–
xxxx@ubuntu:/mnt/hgfs/CCPP$ gcc -c Hello.c
Hello.c: In function ‘main’:
Hello.c:5: error: expected identifier or ‘(’ before ‘&’ token
Hello.c:6: error: ‘x’ undeclared (first use in this function)
Hello.c:6: error: (Each undeclared identifier is reported only once
Hello.c:6: error: for each function it appears in.)

GCC不认识引用’&’吗?还是其他什么原因?希望各位多多指教,谢谢了。O(∩_∩)O~


引用是C++的内容,把gcc改为g++ 试试


很容易出问题


gcc是针对c的,g++可以编译c++

GCC下引用类型解决思路

相关文章:

你感兴趣的文章:

标签云: