void test2(int (&some_array)[3])
This is passing a reference to an array of 3 int
s, eg:
void test2(int (&some_array)[3]) {
...
}
int arr1[3];
test2(arr1); // OK!
int arr2[4];
test2(arr2); // ERROR!
void test3(int (*some_array)[3])
This is passing a pointer to an array of 3 int
s, eg:
void test3(int (*some_array)[3]) {
...
}
int arr1[3];
test3(&arr1); // OK!
int arr2[4];
test3(&arr2); // ERROR!
void test1(int (some_array)[3])
Now, this is where things get a bit interesting.
The parenthesis are optional in this case (they are not optional in the reference/pointer cases), so this is equal to
void test1(int some_array[10])
which in turn is just syntax sugar for
void test1(int some_array[])
(yes, the number is ignored)
which in turn is just syntax sugar for
void test1(int *some_array)
So, not only is the number ignored, but also it is just a simple pointer being passed in. And any fixed array decays to a pointer to its 1st element, which means that any array can be passed in, even though the declaration suggests only 3 elements are allowed, eg:
void test1(int (some_array)[3]) {
...
}
int arr1[3];
test1(arr1); // OK!
int arr2[10];
test1(arr2); // ALSO OK!
int *arr3 = new int[5];
test1(arr3); // ALSO OK!
delete[] arr3;
Live Demo