根据这样的规则:
cv-decomposition
A cv-decomposition of a type T is a sequence of CVi and Pi such that T is
block 引用>"CV(0) P(0) CV(1) P(1) ... CV(n-1) P(n-1) CV(n) U " for n ≥ 0
该规则的示例是:
Example: The type denoted by the type-id
const int **
has three cv-decompositions, taking U as “int”, as “pointer to const int”, and as “pointer to pointer to const int”.根据上面的表格,我可以理解
U
是int
CV(n) 表示const
,但是我不明白为什么它还说pointer to const int
可以表示U
,pointer to pointer to const int
可以表示U
,我对上面表格的理解是U
始终表示 unqualified-cv 基础类型。我的问题:
为什么示例显示
U
可以表示pointer to const int
或pointer to pointer to const int
,不是U
应表示 unqualified-cv 基础类型?上面写着
A cv-decomposition is a sequence of CVi and Pi
,为什么const int **
有三个cv-decompositions
?根据上面的表格,有两个Pi
,即P(0)
和P(1)
,分别是最后一个*
倒数第二个*
,以及相应的CV(i)
是空的。所以我认为类型const int **
,有两个cv-decompositions
,为什么three
?
最佳答案
U
表示原始类型,其中零个或多个最外层“指针”与其相邻的“const”一起被删除。使用 const int **
可以通过三种方式实现此目的。
- U 是指向 const int 的指针(没有删除任何内容)
- U 是指向 const int 的指针(删除了一个“指向”的指针)
- U 是 int(两个“指针”连同其后的“const”一起被删除)
因此存在三个分解。
关于c++ - 关于简历分解的困惑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63097296/