Путаница массив / указатель / ссылка [дубликаты]
Возможный дубликат:
Путаница в C ++
Предположим, я прохожу
int arr[10];
в качестве параметра для функции.
Являются ли все эти действительные прототипы функций? Чем они отличаются с точки зрения аргументов и почему?
Это то, что я знаю до сих пор (не уверен, правильно ли это или нет)
1. void foo(int &arr); //a reference to an array, which preserve the size attribute?
2. void foo(int &arr[]); //the same (is it)?
3. void foo(int (&arr)[]); //I don't know
4. void foo(int &arr[10]); //is it the same as 2?
5. void foo(int (&arr)[10]);//no idea
6. void foo(int *arr); //a decayed pointer of the array, pointing to the first element of the array, losing the size attribute?
7. void foo(int *arr[]); //the same (is it?)
8. void foo(int (*arr)[]); //a pointer to an array, preserve the size
9. void foo(int *arr[10]); //the same as 7 (is it?)
10. void foo(int (*arr)[10]);//is the same as 8 (is it?)
11. void foo(int arr[]); //is the same as 6 (is it?)
12. void foo(int arr[10]); // is the same as 6 (is it?)
(Я знаю, что это потребует длинного объяснения, извините, яя в полном замешательстве ...)