抱歉标题很蹩脚,但我不知道如何更好地描述这个问题。
什么意思:
int (*x)[];
以及如何初始化它?
我知道它不是 int *x[]
因为:
int a,b;
int (*x)[] = {&a, &b};
不会编译。
提前谢谢你。
最佳答案
类型声明具有类似表达式的语法,因此您可以将它们解析为 你会表达:
x x is
*x a pointer
(*x)[] to an array of unknown dimensions
int (*x)[] of int
优先规则是右边的运算符比 左边的那些,在每种情况下,操作符都离元素更近 绑定(bind)更紧密,最后,括号可以用来改变这些 绑定(bind),所以:
int *x[]; is an array of pointers,
int *(x[]); as is this.
int (*x)[]; whereas here, the parentheses change the bindings.
关于C++ 星号和括号运算符一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10350461/