给出一个例子
const int limit = 500;
const int * const cpci = &limit;
const int * const * pcpci = &cpci;
我很难理解最后一行的意思。
基本上,以数组术语来看,值pcpci只是(const int * const)的数组。但是我似乎无法在pcpci内创建多个副本,因为它不应该是一个常量指针。
例如
const int limit = 500;
const int * const cpci = &limit;
const int * const * pcpci = &cpci;
const int limit2 = 600;
const int * const cpci2 = &limit2;
*(pcpci+1) = &cpci2;
在上面代码的最后一行,我收到了“error lvalue must be modifiable”的错误提示。但我想知道为什么会出现这种情况,因为pcpci不是一个常量指针,只有它的元素应该是常量且不可修改的。