【发布时间】:2013-03-14 19:29:21
【问题描述】:
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 不会(显然是因为访问限定符,但逻辑是什么?)。
【问题讨论】:
-
这是整个程序吗?
-
这是我编译的完整 MWE。
标签: c++ warnings member access-specifier