“int*[1]”和“int(*)[1]”有什么区别

What's the differences between `int*[1]` and `int(*)[1]`?

本文关键字:int 什么 区别      更新时间:2023-10-16
using T1 = int*[1];
using T2 = int(*)[1];
T1 t1;
T2 t2;
t1[0] = 0;   // ok
t2[0] = 0;   // error : array type 'int [1]' is not assignable
t2    = t1;  // error : array type 'int [1]' is not assignable
t2    = &t1; // error : array type 'int [1]' is not assignable
t2    = 0;   // ok

为什么t2[0](/t1(不可分配?

int*[1]int(*)[1]有什么区别?

更新:

int n[1];
t2 = &n; // ok

int*[1] 是一个长度为 1 的数组,其元素为 int*

int(*)[1]是一个指针,指向数组int[1]。因此t2[0]是一个数组int[1],它是不可分配的。