【发布时间】:2021-02-04 11:53:16
【问题描述】:
如果一个类只有 const 成员:
struct A {
const int n;
const std::string s;
void f() const;
};
以下几组定义是否等价?
A a1 {...};
const A a2 {...};
A& ref1 = a1;
const A& ref2 = a1;
const A& ref3 = a2;
const 在这种情况下是多余的吗?
【问题讨论】: