stranger123
Programmer
Hi,
I remember a book said we can use *& to pass an array to a function, but now I find it can be done by use * only. For example:
void main()
{
int* myArray = new int[1];
myArray[0]=1;
MyFunction(myArray);
cout<<myArray[0]<<endl;
delete[] myArray;
}
void MyFunction(int* myArray) //void MyFunction(int*& myArray)
{
myArray[0]++;
}
So, what is the difference between * and *& when pass an array to a function?
Can you help?
I remember a book said we can use *& to pass an array to a function, but now I find it can be done by use * only. For example:
void main()
{
int* myArray = new int[1];
myArray[0]=1;
MyFunction(myArray);
cout<<myArray[0]<<endl;
delete[] myArray;
}
void MyFunction(int* myArray) //void MyFunction(int*& myArray)
{
myArray[0]++;
}
So, what is the difference between * and *& when pass an array to a function?
Can you help?