在C语言中,对于简单的情况,似乎为了读取指针声明,你必须向后进行.例如:
int n;
int *p = &n; // p is a pointer to int
int *const np = &n; // np is a const pointer to int
int *const *npp = &np; //npp is a (non-const) pointer to const pointer to (non-const) int
Run Code Online (Sandbox Code Playgroud)
即使解析类型声明的正确方法是通过所谓的螺旋规则,如果解析规则不同以便以另一种方式容纳简单指针声明的读取,这不是更容易吗?例如:
int n;
*int p = &n; // p is a pointer to int
const *int np = &n; // np is a const pointer to int
*const *int npp = &np; // npp is …Run Code Online (Sandbox Code Playgroud)