Chapter 12. Language Reference

Here begins the alphabetic reference. This chapter presents each language keyword with a syntax summary, description, and, in some cases, an example. The syntax summaries use a modified BNF (Backus Normal Form or Backus-Naur Form):

  • Terminal symbols (keywords and operator symbols) are in a constant-width typeface.

  • To avoid ambiguity, a terminal symbol that might be mistaken for a BNF metacharacter (e.g., a vertical bar or a square bracket) is enclosed in quotes (e.g., "|").

  • Nonterminal symbols (syntax elements) are in an italic typeface.

  • Optional elements are in square brackets ([like this]).

  • Choices are separated by vertical bars (|).

  • A production (syntax description) is introduced with := or ::=. The traditional symbol (::=) is used for a complete definition. The abbreviated symbol (:=) is used when the righthand side is incomplete. For example, here is the complete definition of function-specifier as it is given under declaration:

    function-specifier ::= explicit | inline | virtual

    The following is a partial production of function-specifier:

    function-specifier := inline

    The abbreviated symbol (:=) lets you see that the syntax summary is incomplete. Whenever an incomplete rule is used, a cross reference (under "See Also") leads you to the complete rule.

The starting point for parsing a C++ source file (the start symbol) is translation-unit, which you can find under declaration.

C++ syntax is complicated, and even simple statements require an understanding of many different syntax elements. To help you, this chapter duplicates some syntax rules and has plenty of cross references to help you find the parts you need.

Almost every language element is discussed at greater length in Chapter 1-Chapter 7; each description in this chapter includes a reference to the relevant chapter or chapters. References to specific headers (e.g., <new>) are for the corresponding sections in Chapter 13.