重複の可能性:
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?)
(これには長い説明が必要になることを私は知っています、申し訳ありませんが、私は完全に混乱しています...)