A function is a
subprogram that acts on data and often returns a value. You are already
familiar with the one function that every C++ program possesses: int
main(void).
Good C++ programmers write programs
that consist of many of these small functions. These programmers know that a program written with numerous
functions is easier to maintain, update and debug than one very long program.
By programming in a modular (functional) fashion, several programmers can
work independently on separate
functions which can be
assembled at a later date to create the entire project.
Ideally, your main( ) function
should be very short and should consist primarily of function calls.
Each function has its own name. When that name is
encountered in a program, the execution of the program branches to the body of
that function. When the function is finished, execution returns to the
area of the program code from which it was called, and the program continues on
to the next line
of code.
|