A function is a group of statements that together perform a
task. Every C++ program has at least one function, which is main (), and most
programs can define more than one function. A function is made up of 3 parts.
The return type which is used to return a specific line of code, for example
the Boolean return type would make a function that is supposed to call back a
true or false statement. The next part is the function name which is what you
place in order to call the function later on. The final part of the function is
the parameter or the instructions for the function to run. There are 3 steps to
using a function, you have to declare, define and finally use the function. A
function declaration tells the compiler about a function's name, return type,
and parameters. A function definition provides the actual body of the function
and this is where you set up the instructions to the function. After all is
said and done you are now capable of using the function as you please.
No comments:
Post a Comment