7.1.6.1/1包含以下声明(强调我的):
There are two cv-qualifiers,const and volatile. If a cv-qualifier
appears in a decl-specifier-seq,the init-declarator-list of the
declaration shall not be empty.
以上粗体语句的相关性是什么?换句话说,是否可以在decl-specifier-seq中生成cv-unqualified类型的示例,其中声明的init-declarator-list为空?
解决方法
当然,大多数类和枚举定义都使用它:
struct A { }; // valid const struct B { }; // invalid,const would have no meaning const struct C { } c { }; // valid
没有别的. init-declarator-list仅用于简单声明,为此,标准(C 11)声明:
7 Declarations [dcl.dcl]
3 In a simple-declaration,the optional init-declarator-list can be omitted only when declaring a class (Clause 9) or enumeration (7.2),that is,when the decl-specifier-seq contains either a class-specifier,an elaborated-type-specifier with a class-key (9.1),or an enum-specifier.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。