这是来自ISO :标准转换:数组到指针转换的点:$4.4:限定转换/5th点
A multi-level pointer to member type, or a multi-level mixed pointer and
pointer to member type has the form:
cv 0 P 0 to cv 1 P 1 to . . . cv n − 1 P n − 1 to cv n T
where P i is either a pointer or pointer to member and where T is not a
pointer type or pointer to member type.谁能解释一下this.If的可能性?给出一个例子。对那个form.Can来说有什么实际意义吗?有人忽略它吗?类似地,..There在这一部分中有不同形式(限定转换)
发布于 2010-11-25 13:44:10
多级指针是指向指针的指针。
变量通常可以是const或volatile (这些被称为cv限定符)。当你有一个指针时,指向的数据和指针本身都可以有cv限定符。当你有一个多级指针时,任何级别上都可以有cv限定符。
例如:
int i1 = 1;
const int i2 = 2;
int * p1 = &i1; // p1 is a non-constant pointer to a non-constant int
int * const p2 = &i1; // p2 is a constant pointer to a non-constant int
int const * p3 = &i2; // p3 is a non-constant pointer to a constant int
const int * p4 = &i2; // same as p3
int const * const p5 = &i2; // p5 is a constant pointer to a constant int
int * * pp1 = &p1; // non-const pointer to non-const pointer to non-const int
int * * const pp2 = &p1; // const pointer to non-const pointer to non-const int
int * const * pp3 = &p2; // non-const pointer to const pointer to non-const int
int const * * pp4 = &p3; // non-const pointer to non-const pointer to const int
// etc.发布于 2010-11-25 13:36:48
他们只是说你可以有一个指向...to的指针,而不是一个指针。在此过程中的每个步骤中,您都可以使用const和/或volatile。因此,例如,您可以拥有:
int const * volatile *const volatile x;这意味着x是一个常量易失性指针,指向一个常量整数的易失性指针。
https://stackoverflow.com/questions/4274014
复制相似问题