There's generally three things you will see when it comes to functions:
1) Declaration
This isn't the actual code for the function, it is a prototype (blueprint) of what the function looks like. It lets the compiler check that you are using the function correctly, without the need to look at the definition (the actual code). Declarations end in a semicolon ';', and there is no body afterwards
Code:
{ /** Lines to execute in the body */ }
By looking at a declaration, you can tell the return type, and also the variable types the function takes. Names for variables are not necessary in a declaration, but are generally a good idea. It's also a good idea to have a descriptive name, that tells a little about what the function will be doing:
Code:
int Subtract( int left, int right ); // A function that probably returns ( left - right )
// Could also be:
int Subtract( int, int );
2) Definition
This is the actual code that executes when you call the function. You write the code just like you would in the main() function. A function definition has it's own scope, which means that you may declare variables within the function body, and those variables are only available within the fuction (unless you return in some way). Also, the variables passed into the function will be separate copies from the variables elsewhere, unless specified otherwise (If this is the case you will see symbols like '*', or '&', which you will learn more about later):
Code:
int Subtract( int left, int right )
{ // Open the function body
return left - right; // right is subtracted from left, and the result is returned to the caller
} // Close the function body
3) Calling
Calling is when you use the function in other code. Functions are usually written to do specific things. Writing the function lets you neatly wrap a specific behavior that you can then execute on command. This is useful when you will need to call upon this behavior several times while writing your code, but don't want write it out every time. So instead you write the function declaration, and definition, and then call the function like this:
Code:
int main()
{
int A= 10;
int B = 4;
// We call Subtract(), which returns A - B
int Result = Subtract( A, B );
std::cout << Result << "\n";
}