가능한 중복 :
Confusion over C++ pointer and reference topic배열/포인터/참조 혼란
가정하자 내가 함수에 매개 변수로
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?)
(나는 ... 죄송합니다, 나는 완전히 혼란 스러워요,이 긴 설명이 필요 알고)
왜 당신은 귀찮게합니까? 이 숙제가 있니? – fredoverflow
코드에서 닫는 괄호를 확인하십시오 ...너는 그들 중 많은 것을 놓치고있다. –
나는 단지 호기심이 아니다. 그리고 이것은 숙제가 아니다. – Chin