This site hosted by Free.ProHosting.com
Google

Functions: Functions

Applies To: C++Builder 1 or higher
Category: C++ Language

A function is a section of the C++ program that performs a specific task and that can return a value. Its general form is:
 
return_type function_name(parameters)
{

}
 
When the function named function_name is called, all the lines between { and } are executed. Then the function can optionally return back information of the data type specified by return_type. parameters contains a list of variables which will be used as arguments passed to the given function.
 
For example:
 
int calculate(int x, int y)
{
 
}
 
To return a value, use the return keyword:
 
int calculate(int x, int y)
{
    // ...
    return 43;
}
 
If the function does not return a value or if there are no parameters, use the keyword void:
 
void calculate(void)
{
 
}

C++Builder Developer's Network
Copyright © Yoto Yotov