C++ Function Definitions
Function definitions differ from function declarations in that they supply function bodies — the code that makes up the function.
- function-definition :
- decl-specifiersopt declarator ctor-initializeropt fct-body
- fct-body :
As discussed in Functions, the form of the declarator in the syntax is:
dname ( argument-declaration-list ) cv-mod-listopt
The formal arguments declared in argument-declaration-list are in the scope of the function body.
The following figure shows the parts of a function definition. The shaded area is the function body.
Parts of a Function Definition
The cv-mod-list element of the declarator syntax specifies how the this pointer is to be treated; it is only for use with class member functions.
The ctor-initializer element of the syntax is used only in constructors. Its purpose is to allow initialization of base classes and contained objects. (For more information about use of ctor-initializer, see Initializing Bases and Members.)