小编elF*_*eak的帖子

为什么你必须在C中读取指针声明后缀?

在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)

c c++ syntax pointers

3
推荐指数
2
解决办法
308
查看次数

标签 统计

c ×1

c++ ×1

pointers ×1

syntax ×1