cannot convert parameter 1 from 'int *' to 'int &'
int test1(int &e)
{
e=10;
return 1;
}
void main()
{
int *e;
int k=test1(e); //这句出错,我的文件是.cpp
*e=20;
// if(test(e)==1)
if(k)
printf("%d\n",e);
}
cannot convert parameter 1 from 'int *' to 'int &'
A reference that is not to 'const' cannot be bound to a non-lvalue
如果我的文件改为.c来编译会出错
int test1(int &e) //这句出错,在.c的情况下
//error C2143: syntax error : missing ')' before '&'
//error C2143: syntax error : missing '{' before '&'
//error C2059: syntax error : '&'
//error C2059: syntax error : ')'
{
e=10;
return 1;
}
void main()
{
int *e=20;
int k=test1(e);//这句提示warning C4013: 'test1' undefined; assuming extern returning int
if(k)
printf("%d\n",e);
}