Notes concerning Staugaard's presentation of functions
Our class presentation of C++ functions differs from that
of Staugaard's Chapter 7 in certain areas. This note points out
the differences, and guides the student's reading of
Staugaard's text.
- Function Prototypes: The text introduces function
prototypes. The prototype introduces the compiler to the name
of the function, its return type, and the number and type of
its arguments but does not give the code for the function body.
At this time, you should have a reading knowledge of
prototypes, so as to follow the examples in the book.
I will avoid the use of prototypes in class.
- Call by Reference: Despite its intuitive appeal, call
by reference is a difficult concept. Once exercised in the
simple call by value, we will return to call by reference.
For now, you can skip reading about call by reference.
- Default arguments and Function Overloading:
The rules concerning default arguments and overloading are
complicated. You don't have to read this material in the text
at this time. If, out of curiousity, you do read the material,
and want to know what all the complications are about, consider
a function which is both overloaded and has default arguments.
- File Scope:
The names of functions have a scope in the same sense that
local variables do, even though they are enclosed in no
compound statement. They are said to have file scope.
Variables which are in file scope are called global.
We shall not use such global variables.
Read lightly the text's discussion of these concepts.
- Static Variables: The static variable is an advanced
topic, made more difficult by a second use of the word
static for variables in file scope.
Omit reading about static variables.