我一直在阅读C++ Primer
这本书,我有一个问题:
When we ask for a reference to an auto-deduced type, top-level consts in the initializer are not ignored.
As usual, consts are not top-level when we bind a reference to an initializer.
在第一句中,我可以举个例子来理解:
const int ci = 0;
auto &g = ci; // g is a reference of const int, bind to ci
我如何理解第二句话?如何将引用绑定(bind)到初始化程序?
最佳答案
使用 =
符号将引用绑定(bind)到初始化器(迂腐地说,一个对象被用作初始化器)。您发布了一个示例:
auto &g = ci;
初始化器 ci
绑定(bind)到引用 g
。
关于c++ - 如何将引用绑定(bind)到初始化程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33360191/