【发布时间】:2010-05-06 13:14:34
【问题描述】:
我们发现了类似以下的内容(不要问...):
namespace N {
struct A { struct B; };
}
struct A { struct B; };
using namespace N;
struct ::A::B {}; // <- point of interest
有趣的是,这在 VS2005、icc 11.1 和 Comeau(在线)上编译得很好,但在 GCC 上编译失败:
类名的全局限定在'{'标记之前无效
从 C++03 附件 A 开始,在我看来 GCC 是对的:
-
class-head可以由nested-name-specifier和identifier组成 -
nested-name-specifier不能以全局资格开头 (::) - 显然,
identifier也不能
...还是我忽略了什么?
【问题讨论】:
-
听起来与 VS2005 的课程相当。
标签: c++ class standards declaration