RAD Studio
ContentsIndex
PreviousUpNext
Functions

This section contains Function topics.

Name 
Description 
Functions are central to C and C++ programming. Languages such as Delphi distinguish between procedure and function. For C and C++, functions play both roles.
Member functions are sometimes referred to as methods. 
 
Each program must have a single external function named main or WinMain marking the entry point of the program. Functions are usually declared as prototypes in standard or user-supplied header files, or within program files. Functions are external by default and are normally accessible from any file in the program. You can restrict visibility of functions by using the static storage class specifier (see Linkage).
Functions are defined in your source files or made available by linking precompiled libraries.
A given function can be declared several times in a program, provided the declarations are compatible. Nondefining function declarations using... more 
In the Kernighan and Ritchie style of declaration, a function could be implicitly declared by its appearance in a function call, or explicitly declared as follows
<type> func()
where type is the optional return type defaulting to int. In C++, this declaration means <type> func(void). A function can be declared to return any type except an array or function type. This approach does not allow the compiler to check that the type or number of arguments used in a function call match the declaration.
This problem was eased by the introduction of function prototypes with... more 
The general syntax for external function definitions is as follows:
External function definitions  
 
The formal parameter declaration list follows a syntax similar to that of the declarators found in normal identifier declarations. Here are a few examples:  
A function is called with actual arguments placed in the same sequence as their matching formal parameters. The actual arguments are converted as if by initialization to the declared types of the formal parameters.
Here is a summary of the rules governing how the compiler deals with language modifiers and formal parameters in function calls, both with and without prototypes:
  • The language modifiers for a function definition must match the modifiers used in the declaration of the function at all calls to the function.
  • A function can modify the values of its formal parameters, but this has no effect on... more 
Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!