gpt4 book ai didi

c++ - 标准转换 :Qualification conversions

转载 作者:行者123 更新时间:2023-11-30 02:10:50 25 4
gpt4 key购买 nike

这是来自 ISO 的要点:标准转换:数组到指针的转换:$4.4:资格转换/第 5 点

    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.

谁能解释一下。如果可能的话,举个例子..该表格的实际含义。任何人都可以详细说明吗?同样..该部分有不同的形式(资格转换)

最佳答案

多级指针是指向指针的指针。

变量通常可以是 constvolatile(这些称为 cv-qualifiers)。当你有一个指针时,指向的数据和指针本身都可以有 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.

关于c++ - 标准转换 :Qualification conversions,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4274014/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com