相关疑难解决方法(0)

读复杂的const声明的简单规则?

对于读取复杂指针声明,有左右规则.

但是这条规则没有提到如何阅读const修饰语.

例如,在简单的指针声明中,const可以通过多种方式应用:

char *buffer; // non-const pointer to non-const memory
const char *buffer; // non-const pointer to const memory
char const *buffer; // equivalent to previous declartion
char * const buffer = {0}; // const pointer to non-const memory
char * buffer const = {0}; // error
const char * const buffer = {0}; // const pointer to const memory
Run Code Online (Sandbox Code Playgroud)

现在用const指针声明指针怎么样?

char **x; // no const;
const char **x;
char * …
Run Code Online (Sandbox Code Playgroud)

c c++ const declaration

42
推荐指数
2
解决办法
1万
查看次数

标签 统计

c ×1

c++ ×1

const ×1

declaration ×1