[gram.class]

# Annex A (informative) Grammar summary [[gram]](./#gram)

## A.9 Classes [gram.class]

[class-name:](class.pre#nt:class-name "11.1 Preamble [class.pre]")  
[*identifier*](lex.name#nt:identifier "5.11 Identifiers [lex.name]")  
[*simple-template-id*](temp.names#nt:simple-template-id "13.3 Names of template specializations [temp.names]")

[class-specifier:](class.pre#nt:class-specifier "11.1 Preamble [class.pre]")  
[*class-head*](class.pre#nt:class-head "11.1 Preamble [class.pre]") { [*member-specification*](class.mem.general#nt:member-specification "11.4.1 General [class.mem.general]")opt }

[class-head:](class.pre#nt:class-head "11.1 Preamble [class.pre]")  
[*class-key*](class.pre#nt:class-key "11.1 Preamble [class.pre]") [*attribute-specifier-seq*](dcl.attr.grammar#nt:attribute-specifier-seq "9.13.1 Attribute syntax and semantics [dcl.attr.grammar]")opt [*class-head-name*](class.pre#nt:class-head-name "11.1 Preamble [class.pre]") [*class-property-specifier-seq*](class.pre#nt:class-property-specifier-seq "11.1 Preamble [class.pre]")opt [*base-clause*](class.derived.general#nt:base-clause "11.7.1 General [class.derived.general]")opt  
[*class-key*](class.pre#nt:class-key "11.1 Preamble [class.pre]") [*attribute-specifier-seq*](dcl.attr.grammar#nt:attribute-specifier-seq "9.13.1 Attribute syntax and semantics [dcl.attr.grammar]")opt [*base-clause*](class.derived.general#nt:base-clause "11.7.1 General [class.derived.general]")opt

[class-head-name:](class.pre#nt:class-head-name "11.1 Preamble [class.pre]")  
[*nested-name-specifier*](expr.prim.id.qual#nt:nested-name-specifier "7.5.5.3 Qualified names [expr.prim.id.qual]")opt [*class-name*](class.pre#nt:class-name "11.1 Preamble [class.pre]")

[class-property-specifier-seq:](class.pre#nt:class-property-specifier-seq "11.1 Preamble [class.pre]")  
[*class-property-specifier*](class.pre#nt:class-property-specifier "11.1 Preamble [class.pre]") [*class-property-specifier-seq*](class.pre#nt:class-property-specifier-seq "11.1 Preamble [class.pre]")opt

[class-property-specifier:](class.pre#nt:class-property-specifier "11.1 Preamble [class.pre]")  
final  
trivially_relocatable_if_eligible  
replaceable_if_eligible

[class-key:](class.pre#nt:class-key "11.1 Preamble [class.pre]")  
class  
struct  
union

[member-specification:](class.mem.general#nt:member-specification "11.4.1 General [class.mem.general]")  
[*member-declaration*](class.mem.general#nt:member-declaration "11.4.1 General [class.mem.general]") [*member-specification*](class.mem.general#nt:member-specification "11.4.1 General [class.mem.general]")opt  
[*access-specifier*](class.derived.general#nt:access-specifier "11.7.1 General [class.derived.general]") : [*member-specification*](class.mem.general#nt:member-specification "11.4.1 General [class.mem.general]")opt

[member-declaration:](class.mem.general#nt:member-declaration "11.4.1 General [class.mem.general]")  
[*attribute-specifier-seq*](dcl.attr.grammar#nt:attribute-specifier-seq "9.13.1 Attribute syntax and semantics [dcl.attr.grammar]")opt [*decl-specifier-seq*](dcl.spec.general#nt:decl-specifier-seq "9.2.1 General [dcl.spec.general]")opt [*member-declarator-list*](class.mem.general#nt:member-declarator-list "11.4.1 General [class.mem.general]")opt ;  
[*function-definition*](dcl.fct.def.general#nt:function-definition "9.6.1 General [dcl.fct.def.general]")  
[*friend-type-declaration*](class.mem.general#nt:friend-type-declaration "11.4.1 General [class.mem.general]")  
[*using-declaration*](namespace.udecl#nt:using-declaration "9.10 The using declaration [namespace.udecl]")  
[*using-enum-declaration*](enum.udecl#nt:using-enum-declaration "9.8.2 The using enum declaration [enum.udecl]")  
[*static_assert-declaration*](dcl.pre#nt:static_assert-declaration "9.1 Preamble [dcl.pre]")  
[*consteval-block-declaration*](dcl.pre#nt:consteval-block-declaration "9.1 Preamble [dcl.pre]")  
[*template-declaration*](temp.pre#nt:template-declaration "13.1 Preamble [temp.pre]")  
[*explicit-specialization*](temp.expl.spec#nt:explicit-specialization "13.9.4 Explicit specialization [temp.expl.spec]")  
[*deduction-guide*](temp.deduct.guide#nt:deduction-guide "13.7.2.3 Deduction guides [temp.deduct.guide]")  
[*alias-declaration*](dcl.pre#nt:alias-declaration "9.1 Preamble [dcl.pre]")  
[*opaque-enum-declaration*](dcl.enum#nt:opaque-enum-declaration "9.8.1 Enumeration declarations [dcl.enum]")  
[*empty-declaration*](dcl.pre#nt:empty-declaration "9.1 Preamble [dcl.pre]")

[member-declarator-list:](class.mem.general#nt:member-declarator-list "11.4.1 General [class.mem.general]")  
[*member-declarator*](class.mem.general#nt:member-declarator "11.4.1 General [class.mem.general]")  
[*member-declarator-list*](class.mem.general#nt:member-declarator-list "11.4.1 General [class.mem.general]") , [*member-declarator*](class.mem.general#nt:member-declarator "11.4.1 General [class.mem.general]")

[member-declarator:](class.mem.general#nt:member-declarator "11.4.1 General [class.mem.general]")  
[*declarator*](dcl.decl.general#nt:declarator "9.3.1 General [dcl.decl.general]") [*virt-specifier-seq*](class.mem.general#nt:virt-specifier-seq "11.4.1 General [class.mem.general]")opt [*function-contract-specifier-seq*](dcl.contract.func#nt:function-contract-specifier-seq "9.4.1 General [dcl.contract.func]")opt [*pure-specifier*](class.mem.general#nt:pure-specifier "11.4.1 General [class.mem.general]")opt  
[*declarator*](dcl.decl.general#nt:declarator "9.3.1 General [dcl.decl.general]") [*requires-clause*](temp.pre#nt:requires-clause "13.1 Preamble [temp.pre]") [*function-contract-specifier-seq*](dcl.contract.func#nt:function-contract-specifier-seq "9.4.1 General [dcl.contract.func]")opt  
[*declarator*](dcl.decl.general#nt:declarator "9.3.1 General [dcl.decl.general]") [*brace-or-equal-initializer*](dcl.init.general#nt:brace-or-equal-initializer "9.5.1 General [dcl.init.general]")  
[*identifier*](lex.name#nt:identifier "5.11 Identifiers [lex.name]")opt [*attribute-specifier-seq*](dcl.attr.grammar#nt:attribute-specifier-seq "9.13.1 Attribute syntax and semantics [dcl.attr.grammar]")opt : [*constant-expression*](expr.const#nt:constant-expression "7.7 Constant expressions [expr.const]") [*brace-or-equal-initializer*](dcl.init.general#nt:brace-or-equal-initializer "9.5.1 General [dcl.init.general]")opt

[virt-specifier-seq:](class.mem.general#nt:virt-specifier-seq "11.4.1 General [class.mem.general]")  
[*virt-specifier*](class.mem.general#nt:virt-specifier "11.4.1 General [class.mem.general]") [*virt-specifier-seq*](class.mem.general#nt:virt-specifier-seq "11.4.1 General [class.mem.general]")opt

[virt-specifier:](class.mem.general#nt:virt-specifier "11.4.1 General [class.mem.general]")  
override  
final

[pure-specifier:](class.mem.general#nt:pure-specifier "11.4.1 General [class.mem.general]")  
= 0

[friend-type-declaration:](class.mem.general#nt:friend-type-declaration "11.4.1 General [class.mem.general]")  
friend [*friend-type-specifier-list*](class.mem.general#nt:friend-type-specifier-list "11.4.1 General [class.mem.general]") ;

[friend-type-specifier-list:](class.mem.general#nt:friend-type-specifier-list "11.4.1 General [class.mem.general]")  
[*friend-type-specifier*](class.mem.general#nt:friend-type-specifier "11.4.1 General [class.mem.general]") ...opt  
[*friend-type-specifier-list*](class.mem.general#nt:friend-type-specifier-list "11.4.1 General [class.mem.general]") , [*friend-type-specifier*](class.mem.general#nt:friend-type-specifier "11.4.1 General [class.mem.general]") ...opt

[friend-type-specifier:](class.mem.general#nt:friend-type-specifier "11.4.1 General [class.mem.general]")  
[*simple-type-specifier*](dcl.type.simple#nt:simple-type-specifier "9.2.9.3 Simple type specifiers [dcl.type.simple]")  
[*elaborated-type-specifier*](dcl.type.elab#nt:elaborated-type-specifier "9.2.9.5 Elaborated type specifiers [dcl.type.elab]")  
[*typename-specifier*](temp.res.general#nt:typename-specifier "13.8.1 General [temp.res.general]")

[conversion-function-id:](class.conv.fct#nt:conversion-function-id "11.4.8.3 Conversion functions [class.conv.fct]")  
operator [*conversion-type-id*](class.conv.fct#nt:conversion-type-id "11.4.8.3 Conversion functions [class.conv.fct]")

[conversion-type-id:](class.conv.fct#nt:conversion-type-id "11.4.8.3 Conversion functions [class.conv.fct]")  
[*type-specifier-seq*](dcl.type.general#nt:type-specifier-seq "9.2.9.1 General [dcl.type.general]") [*conversion-declarator*](class.conv.fct#nt:conversion-declarator "11.4.8.3 Conversion functions [class.conv.fct]")opt

[conversion-declarator:](class.conv.fct#nt:conversion-declarator "11.4.8.3 Conversion functions [class.conv.fct]")  
[*ptr-operator*](dcl.decl.general#nt:ptr-operator "9.3.1 General [dcl.decl.general]") [*conversion-declarator*](class.conv.fct#nt:conversion-declarator "11.4.8.3 Conversion functions [class.conv.fct]")opt

[base-clause:](class.derived.general#nt:base-clause "11.7.1 General [class.derived.general]")  
: [*base-specifier-list*](class.derived.general#nt:base-specifier-list "11.7.1 General [class.derived.general]")

[base-specifier-list:](class.derived.general#nt:base-specifier-list "11.7.1 General [class.derived.general]")  
[*base-specifier*](class.derived.general#nt:base-specifier "11.7.1 General [class.derived.general]") ...opt  
[*base-specifier-list*](class.derived.general#nt:base-specifier-list "11.7.1 General [class.derived.general]") , [*base-specifier*](class.derived.general#nt:base-specifier "11.7.1 General [class.derived.general]") ...opt

[base-specifier:](class.derived.general#nt:base-specifier "11.7.1 General [class.derived.general]")  
[*attribute-specifier-seq*](dcl.attr.grammar#nt:attribute-specifier-seq "9.13.1 Attribute syntax and semantics [dcl.attr.grammar]")opt [*class-or-decltype*](class.derived.general#nt:class-or-decltype "11.7.1 General [class.derived.general]")  
[*attribute-specifier-seq*](dcl.attr.grammar#nt:attribute-specifier-seq "9.13.1 Attribute syntax and semantics [dcl.attr.grammar]")opt virtual [*access-specifier*](class.derived.general#nt:access-specifier "11.7.1 General [class.derived.general]")opt [*class-or-decltype*](class.derived.general#nt:class-or-decltype "11.7.1 General [class.derived.general]")  
[*attribute-specifier-seq*](dcl.attr.grammar#nt:attribute-specifier-seq "9.13.1 Attribute syntax and semantics [dcl.attr.grammar]")opt [*access-specifier*](class.derived.general#nt:access-specifier "11.7.1 General [class.derived.general]") virtualopt [*class-or-decltype*](class.derived.general#nt:class-or-decltype "11.7.1 General [class.derived.general]")

[class-or-decltype:](class.derived.general#nt:class-or-decltype "11.7.1 General [class.derived.general]")  
[*nested-name-specifier*](expr.prim.id.qual#nt:nested-name-specifier "7.5.5.3 Qualified names [expr.prim.id.qual]")opt [*type-name*](dcl.type.simple#nt:type-name "9.2.9.3 Simple type specifiers [dcl.type.simple]")  
[*nested-name-specifier*](expr.prim.id.qual#nt:nested-name-specifier "7.5.5.3 Qualified names [expr.prim.id.qual]") template [*simple-template-id*](temp.names#nt:simple-template-id "13.3 Names of template specializations [temp.names]")  
[*computed-type-specifier*](dcl.type.simple#nt:computed-type-specifier "9.2.9.3 Simple type specifiers [dcl.type.simple]")

[access-specifier:](class.derived.general#nt:access-specifier "11.7.1 General [class.derived.general]")  
private  
protected  
public

[ctor-initializer:](class.base.init#nt:ctor-initializer "11.9.3 Initializing bases and members [class.base.init]")  
: [*mem-initializer-list*](class.base.init#nt:mem-initializer-list "11.9.3 Initializing bases and members [class.base.init]")

[mem-initializer-list:](class.base.init#nt:mem-initializer-list "11.9.3 Initializing bases and members [class.base.init]")  
[*mem-initializer*](class.base.init#nt:mem-initializer "11.9.3 Initializing bases and members [class.base.init]") ...opt  
[*mem-initializer-list*](class.base.init#nt:mem-initializer-list "11.9.3 Initializing bases and members [class.base.init]") , [*mem-initializer*](class.base.init#nt:mem-initializer "11.9.3 Initializing bases and members [class.base.init]") ...opt

[mem-initializer:](class.base.init#nt:mem-initializer "11.9.3 Initializing bases and members [class.base.init]")  
[*mem-initializer-id*](class.base.init#nt:mem-initializer-id "11.9.3 Initializing bases and members [class.base.init]") ( [*expression-list*](expr.post.general#nt:expression-list "7.6.1.1 General [expr.post.general]")opt )  
[*mem-initializer-id*](class.base.init#nt:mem-initializer-id "11.9.3 Initializing bases and members [class.base.init]") [*braced-init-list*](dcl.init.general#nt:braced-init-list "9.5.1 General [dcl.init.general]")

[mem-initializer-id:](class.base.init#nt:mem-initializer-id "11.9.3 Initializing bases and members [class.base.init]")  
[*class-or-decltype*](class.derived.general#nt:class-or-decltype "11.7.1 General [class.derived.general]")  
[*identifier*](lex.name#nt:identifier "5.11 Identifiers [lex.name]")
