Function definitions

The elements of a function definition are as follows:

IBM extension begins In addition, for compatibility with GNU C and C++, XL C/C++ allows you to use attributes to modify the properties of functions. They are described in Function attributes (IBM extension).IBM extension ends

Function definitions take the following form:

Read syntax diagramSkip visual syntax diagram
Function definition syntax (C only)

>>-+-------------------------+--+--------------------+---------->
   '-storage_class_specifier-'  '-function_specifier-'   

>--+-----------------------+--function_declarator--{------------>
   '-return_type_specifier-'                           

>--function body--}--------------------------------------------><

Read syntax diagramSkip visual syntax diagram
Function definition syntax (C++ only)

>>-+-------------------------+--+--------------------+---------->
   '-storage_class_specifier-'  '-function_specifier-'   

>--return_type_specifier--function_declarator------------------->

>--+-+----------------------------+-{--function body--}-+------><
   | '-:--constructor-initializer-'                     |   
   +-try-block------------------------------------------+   
   |             (1)                                    |   
   +- = default;----------------------------------------+   
   |            (2)                                     |   
   '- = delete;-----------------------------------------'   

Notes:
  1. This syntax is valid only in the C++11 standard.
  2. This syntax is valid only in the C++11 standard.
C++11
Note: When function_declarator incorporates a trailing return type, return_type_specifer must be auto. For more information about trailing return type, see Trailing return type (C++11).
C++11