아래 그림과 같이 Test
배열에 할당하는 방법을 이해하는 데 문제가 있습니다.
int (*&Test)[10] = Parray;
Test
은 10 개의 정수 배열에 대한 포인터에 대한 참조입니다. 나는 완전히 이것을 이해하지 않고 내 연구를 수행 한배열에 할당하는 방법 int (* & Test) [10]?
error: incompatible types in assignment of 'int*' to 'int [10]'|.
다음과 같이
내가 오류입니다. 저는 C++ Primer 5 판을 읽고 있습니다.
int main() {
int arr[10];
int n = 5;
int *ptr1 = &n;
int arr2[10];
int *ptrs[10]; // ptrs is an array of ten pointers
// Parray points to an array of ten ints
int (*Parray)[10] = &arr;
// arrRef refers to an array of ten ints
int (&arrRef)[10] = arr2;
// Test is a reference to a pointer to an array of ten ints.
int (*&Test)[10] = Parray;
// How can I assign to Test[0..1..2..etc]?
// This is what I am trying to do:
Test[0] = ptr1; // Error here
return 0;
}
Test[0]
등으로 어떻게 할당 할 수 있습니까?
아니요 테스트는 10 개의 정수 배열을 가리키는 포인터에 대한 참조입니다. – texasbruce
^'arr'과 같은 유형입니다. 포인터 배열을 원한다면 어딘가에서 'ptrs'변수를 사용해야합니다. – Aralox
'ptr1'은 초기화되지 않은 포인터입니다. 여기서'ptr1'과'ptrs'로 무엇을하기를 희망하는지 명확하지 않습니다 –