Unit III: Functions
Lecture notes
- Notes for class III.1: A first look at arrays
- Notes for class III.2: Functions
- There are no notes for class III.3.
- Notes for class III.4: More on functions
- There are no notes for class III.5.
Sample Programs
- Here's arrays.cpp, the
array example from class III.1.
- Here's fox.cpp, the program we used
in Lab 3.
- There's also better-fox.cpp,
which is a nicer version of the same program (but one which uses some more
advanced features).
- Here's swap.cpp, the
example that uses reference parameters.
Reading
Most of this unit is on functions (which in C++ are also called "methods").
Chapter 4 of the textbook talks about functions. You should read
this. (This doesn't cover reference parameters, since the textbook
doesn't talk about those until it covers pointers in Chapter 6)
The first lecture of this unit took a quick look at the basic features
of arrays. The textbook covers arrays in Chapter 5, so you might want
to take a look at the start of Chapter 5 as well. If you don't, no
worries, we'll get to arrays in lots of detail in Unit IV.