Functions Intro
A function is a sequence of statements collected under a single name
(the function's name). A simple example of a function declaration is:
void aFunction()
{
cout << "First function statement" << endl;
cout << "Second function statement" << endl;
}
aFunction() is the function's name.
The function's name can be used to call the function:
i.e. to get the function's body executed.
Example
#include <iostream>
using namespace std;
void aFunction() // function definition
{ // start of the function's implementation
cout << "First function statement" << endl;
cout << "Second function statement" << endl;
} // end of the function's implementation
int main()
{
aFunction(); // function call
aFunction(); // another function call
}
Output
First function statement
Second function statement
First function statement
Second function statement