<分区>
我正在阅读 C++ primer,但我一直停留在这个主题上。据记载
int i=0;
const int ci=42; //const is top level.
const int *p2=&ci; //const is low level.
const int *const p3=p2; //rightmost const is top level,left one is low level.
int *p=p3 //error.
p2=p3 //ok:p2 has the same low level constant qualification as p3.
int &r=ci; //error: can't bind an ordinary int to const int object
const int &r2=i; //ok:can bind const int to plain int.
现在如果在最后一条语句中忽略了顶级常量,那么它应该给出一个错误,因为 &r2
和 i 的低级常量限定是不一样的。为什么最后的陈述是正确的??