【发布时间】:2018-01-04 12:37:39
【问题描述】:
我正在尝试理解这段代码。我一直在弄清楚为什么d 和e 是int* 和const int*。我需要一些帮助。
const int ci = i, &cr = ci;
auto b = ci; // b is an int (top-level const in ci is dropped)
auto c = cr; // c is an int (cr is an alias for ci whose const is top-level)
auto d = &i; // d is an int*(& of an int object is int*)
auto e = &ci; // e is const int*(& of a const object is low-level const)
【问题讨论】:
-
请提供minimal reproducible example。您的代码中缺少
i的定义。