Why does this code require the '&' in array syntax?
int (&returnArray(int (&arr)[42]))[42]
{
return arr;
}
When i declare it like this
int (returnArray(int arr[42]))[42]
{
return arr;
}
i get
error C2090: function returns array
But isn't this an array it was returning in the first example? Was it some sort of a reference to array?
I know i can also pass an array to a function, where it will decay to a pointer
int returnInt(int arr[42])
{
return arr[0];
}
or pass it by reference
int returnInt(int (&arr)[42])
{
return arr[0];
}
But why can't i return an array the same way it can be passed?