[求助]C++中的参数问题
#include<iostream.h>
void app(int * & pa,int n);
void main()
{
int *ary=0,*t;
int i,n;
cout<<"n=";
cin>>n;
app(ary,n);
for(t=ary;t<ary+n;t++)
cout<<*t<<" ";
cout<<endl;
for(i=0;i<n;i++)
ary[i]=10+i;
for(i=0;i<n;i++)
cout<<ary[i]<<" ";
cout<<endl;
delete []ary;
ary=0;
}
void app(int * & pa,int len)
{
pa=new int[len];
if(pa==0)
{
cout<<"allocation faiure";return;
}
for(int i=0;i<len;i++)
pa[i]=0;
}
为什么在APP函数中要用引用参数啊。不用对程序有影响吗。我认为可以啊
希望高手指点啊