Function definitions have the form
function-definition: attribute-specifier-seqopt decl-specifier-seqopt declarator virt-specifier-seqopt function-body
function-body: ctor-initializeropt compound-statement function-try-block = default ; = delete ;
Any informal reference to the body of a function should be interpreted as a reference to the non-terminal function-body. The optional attribute-specifier-seq in a function-definition appertains to the function. A virt-specifier-seq can be part of a function-definition only if it is a member-declaration ([class.mem]).
The declarator in a function-definition shall have the form
D1 ( parameter-declaration-clause ) cv-qualifier-seqopt ref-qualifieropt exception-specificationopt attribute-specifier-seqopt trailing-return-typeopt
as described in [dcl.fct]. A function shall be defined only in namespace or class scope.
[ Example: a simple example of a complete function definition is
int max(int a, int b, int c) { int m = (a > b) ? a : b; return (m > c) ? m : c; }
Here int is the decl-specifier-seq; max(int a, int b, int c) is the declarator; { /* ... */ } is the function-body. — end example ]
A ctor-initializer is used only in a constructor; see [class.ctor] and [class.init].
A cv-qualifier-seq or a ref-qualifier (or both) can be part of a non-static member function declaration, non-static member function definition, or pointer to member function only ([dcl.fct]); see [class.this].
[ Note: Unused parameters need not be named. For example,
void print(int a, int) { std::printf("a = %d\n",a); }
— end note ]
In the function-body, a function-local predefined variable denotes a block-scope object of static storage duration that is implicitly defined (see [basic.scope.local]).
The function-local predefined variable __func__ is defined as if a definition of the form
static const char __func__[] = "function-name";
had been provided, where function-name is an implementation-defined string. It is unspecified whether such a variable has an address distinct from that of any other object in the program.102
[ Example:
struct S { S() : s(__func__) { } // OK const char *s; }; void f(const char * s = __func__); // error: __func__ is undeclared
— end example ]
Implementations are permitted to provide additional predefined variables with names that are reserved to the implementation ([global.names]). If a predefined variable is not odr-used ([basic.def.odr]), its string value need not be present in the program image.