C++ CH6
function
A _____ is a collection of statements that performs a specific task.
stub
A _____ is a dummy function that is called instead of the actual function it represents. It usually displays a test message acknowledging that it was called, and nothing more.
value returning function
A _____ is a function that returns a value. the pow function is an example.
driver
A _____ is a program that tests a function by simply calling it. If the function accepts arguments, the driver passes test data. If the function returns a value, the driver displays the return value on the screen.
parameter
A _____ is a special variable that holds a value being passed into a function.
reference variable
A _____ is an alias for another variable. Any changes made to the reference variable are actually performed on the variable for which it is an alias.
modular
A _____ program is broken up into functions that perform specific tasks.
return type
A function can send a value to the part of the program that executed it. The return type is the data type of the value that is sent from the function.
lifetime
A function's local variables exist only while the function is executing. This is known as the _____ of a local variable.
static local variable
A variable that can be stored after a function is done. 'static int num' is an example.
void functions
Some functions simply perform one or more statements, which follows terminate. These are called _____.
function signature
The _____ is the name of the function and the data types of the function's parameters in the proper order.
return type, name, parameter list
The function header declares the function's _____ _____ and _____.
Parameter list
The program can send data into a function. The parameter list is a list of variables that hold the values being passed into the function
warning.
WARNING! Don't get carried away with using reference variables as function parameters. Any time you allow a function to alter a variable that's outside the function, you are creating potential debugging problems. Reference variables should only be used as parameters when the situation requires them.
passed by reference
When a reference parameter is used, it is said that the argument is _____.
Name
You should give each function a descriptive name. In general, the same rules that apply to variable names also apply to function names.
stubs drivers
_____ and _____ are very helpful tools for testing and debugging programs that use functions. They allow you to test the individual functions in a program, in isolation from the parts of the program that call the functions.
function prototype
a _____ eliminates the need to place a function definition before all calls to the function.
global constant
a _____ is a named constant that is available to every function in a program.
concept.
concept. A function call is a statement that causes a function to execute. A function definition contains the statements that make up the function.
concept.
concept. A function may send a value back to the part of the program that called the function.
concept.
concept. A local variable is defined inside a function and is not accessible outside the function. A global variable is defined outside all functions and is accessible to all functions in its scope.
concept.
concept. A program may be broken up into manageable functions.
concept.
concept. Default arguments are passed into parameters automatically if no argument is provided in the function call.
concept.
concept. Functions are ideal for use in menu-driven programs. When the user selects an item from a menu, the program can call the appropriate function.
concept.
concept. Functions may return true or false values.
concept.
concept. The exit( ) function causes a program to terminate, regardless of which function or control mechanism is executing.
concept.
concept. When a function is called, the program may send values into the function. these values are called arguments.
concept.
concept. When an argument is passed into a parameter , only a copy of the argument's value is passed. Changes to the parameter do not affect the original argument.
concept.
concept. When used as parameters, reference variables allow a function to access the parameter's original argument. Changes to the parameter are also made to the argument.
concept.
concept. two or more functions may have the same name, as long as their parameter lists are different.
note.
note. When a program works with a reference variable, it is actually working with the variable it references, or points to.
note.
note. function prototypes are also known as function declarations.
note.
note. parameters with default arguments must be defined last.
note.
note. reference variable ex: void doubleNum(int &refVar) { refVar *= 2; } note: The variable refVar is called "a reference to an int ."
note.
note. the exit function requires the cstdlib header file.
note.
note. the function prototype must list the data type of each parameter.
return
the _____ statement causes a function to end immediately.
function header
the line in the definition that reads int main ( ) is called the function header.
local variables
variables that are defined inside a function are called _____.
warning
warning. you must place either the function definition or the function prototype ahead of all calls to that function.
passed by value
when only a copy of an argument is passed to a function, it is said to be _____.