r****o 发帖数: 1950 | 1 关于const和volatile,我们知道他们可以修饰变量,也可以修饰指针,如下所述。
int a;
const int *p = a;
volatile int *p = a;
//结论:这里const或volatile修饰a,
int * const p = a;
int * volatile p = a;
//结论:这里const或volatile修饰指针p
我想问的是如果这里是pointer-to-pointer,例如
const int **p = a;
volatile int **p = a;
或
int ** const p = a;
int ** volatile p = a;
上面的结论是否还成立?另外,如果const或volatile修饰指针,这里是修饰的第几级
指针呢?还是一级指针和二级指针都被修饰? |
S**I 发帖数: 15689 | 2
还是修饰a
还是修饰p
当然只修饰指针的指针了
【在 r****o 的大作中提到】 : 关于const和volatile,我们知道他们可以修饰变量,也可以修饰指针,如下所述。 : int a; : const int *p = a; : volatile int *p = a; : //结论:这里const或volatile修饰a, : int * const p = a; : int * volatile p = a; : //结论:这里const或volatile修饰指针p : 我想问的是如果这里是pointer-to-pointer,例如 : const int **p = a;
|
s*****n 发帖数: 5488 | 3 用*划线。
【在 r****o 的大作中提到】 : 关于const和volatile,我们知道他们可以修饰变量,也可以修饰指针,如下所述。 : int a; : const int *p = a; : volatile int *p = a; : //结论:这里const或volatile修饰a, : int * const p = a; : int * volatile p = a; : //结论:这里const或volatile修饰指针p : 我想问的是如果这里是pointer-to-pointer,例如 : const int **p = a;
|