Code:
int InitialiseArray ( int &[] ArgArrayName , int ArgInitValue )
There, you are declaring an array of references to int-- this is not allowed because references must be initialized to reference something and they may not be changed. Those are two things that arrays cannot provide.
Given that, it would probably be beneficial for you to know that you do not need to pass arrays as references because arrays are always passed by reference-- they actually decay into pointers.
So, you can prototype your function like this:
Code:
int InitialiseArray ( int ArgArrayName[], int ArgInitValue )
// or
int InitialiseArray ( int* ArgArrayName , int ArgInitValue )
Also, because arrays decay to pointers, you do not need to take the address of it in the function call. So you can call it like this:
Code:
InitialiseArray( Foo, 0);
But, there is one obvious flaw inside your function. Take a look at this code:
Code:
for (Element = 0 ; Element < sizeof ArgArrayName ; Element ++ )
Unfortunately, the fact that arrays decay into pointers is exactly what is causing your problem here. sizeof will not return the number of elements in the array. Instead, it will return the size of the ArgArrayName variable which will be whatever the size of a pointer type is on your machine (probably 4 bytes). To fix this, you'll need to pass the size of your array along with the other parameters in this function and use that value as the condition for your for loop.
Just as an aside-- if this is your actual code, you can replace the whole thing with one simple statement:
Code:
int Foo[6] = { 0 };
That will create an array of 6 integers and set them all to 0.
-tf