class Foo
{
public:
const int x;
};
class Bar
{
private:
const int x;
};
输出:
test.cpp:10:13: warning: non-static const member ‘const int Bar::x’ in class without a constructor [-Wuninitialized]
为什么会Bar
产生警告但Foo
没有(显然是因为访问限定符,但逻辑是什么?)。