answersLogoWhite

0

// declaration:

return_type function_name([argument_type_1[=value][, argument_type_2[=value][, ...]]]);

// definition (function signature must match declaration):

return_type function_name([argument_type_1 argument_name_1[, argument_type_2 argument_name_2[, ...]]])

{

// implementation

}

In the case of separate declaration/definition, the definition file must include the file that contains the declaration unless they are both in the same file. If the function is a template function, both the declaration and the definition must be visible to the compiler BEFORE it can be used (thus they must both be in the same file). For all other functions other than inline expanded functions, only the declaration need be visible.

Note that the definition is also a declaration, however default values must be omitted and all arguments must be named. The declaration arguments may also be named but they needn't match those in the definition (the definition names are the ones actually used).

Alternatively:

// combined declaration and definition:

return_type function_name([argument_type_1 argument_name_1[=value][, argument_type_2 argument_name_2[=value][, ...]]])

{

// implementation

}

Functions that are defined in the declaration are impicitly inline expanded. Functions that are defined separately must be prepended with the inline keyword in the definition, and the definition must be visible to the compiler BEFORE the function can be used.

Functions that do not return a value must return void. If any other return type is specified, the function must explicitly return that type via all return paths. The main function must return an int, however return(0) is implied if not specified in the final statement.

User Avatar

Wiki User

11y ago

What else can I help you with?