COM1101 Winter 2001 Prof. Futrelle -- Midterm Exam Topics
A good deal of important ideas have been covered in the
lengthy discussion that I have written for Quiz #2.
The list below goes systematically through your textbook, emphasizing important
material that will be covered on the Midterm exam on Wednesday, February 14th.
Of course not every topic mentioned below can be included on a single midterm.
But I have confined the list to a rather small set of topics so you can concentrate
your energies and not simply study hundreds of pages without guidance.
Summarizing the topics empahsized below, I would say that most importantly,
you need to understand
function definitions and use, including value and reference parameters, class definitions
including definition and use of member functions, and arrays, including their
use in functions.
In keeping with my discussion of Quiz #2, there will be no cases in which
standard I/O will be used on the Midterm. Also, no file I/O.
The overuse of cin and cout has caused confusion about the
passing of values to functions when they are called and the return of values
by functions as their result after they have executed.
-
Chapter 2 covers the basics of C++. You should know thoroughly everything
in this one chapter, but ignore all discussions of cin and cout.
-
For Chapter 3 you do not have to memorize predefined function names such
as sqrt(), Table 3.2. You must know how to properly write a function call.
You must know how to define a function, with a return type and types specs
for arguments. You must know the difference between a prototype, no "{...}"
and a definition. Definitions must have formal parameter names.
The prototype and definition arg lists much match in detail, but not the
formal parameter names. Local variables: Exist only when the function is
running; vanish when it ends (unless returned). (Exceptions for reference
variables and pointers, but not in this chapter.) The concept of call-by-value.
How globals are used
and how they can be overridden by redefinition in other scopes. I have not
stressed overloading functions; it will not be on the Midterm.
-
Chapter 4 discusses void functions; they can have no return statement and
nothing can be assigned to when they return -- they return no value of any kind.
There will most likely be one simple question on the use of a reference parameter,
e.g., is the expression 3 == fun(2) true when a certain definition I'll give you
of fun() is given using a reference parameter or I ask you to write such a function.
The summary on pg. 191 might help. Of course functions can call other functions.
That's a nice concept that I can use to test your understanding, e.g.,
the value of fun1(3, fun2(677, fun6(1))).
Here's something that you might call a trick question, but that illustrates
important principles. I could give you function definitions, some of which
pass by value and some by reference. Only the ones that pass by reference can
change their arguments. Changes to arguments passed by value
are lost unless specifically returned
with a return statement. If you can sort this out in an example such as the
fun1, fun2, fun6 example above, you'll do fine.
-
Because of my concerns about the overemphasis on I/O, I'm going to skip Chapter
5 on the Midterm. (Isn't that nice ;-)
-
Chapter 6 on classes is important. It's your first introduction to object-oriented
programming. I will ask very basic questions about classes, similar to the ones
on Quiz #2. This is material you'll have to study carefully. You must clearly
understand the difference between classes and instances (the latter are also called
"objects"). A class is a design, a template that lays out what data each object can
contain, its member variables, and what functions can operate on an object, its
member functions. Thus, the Car class may state that each and every car object will
have its own speed and its own position as well as the function setSpeed(double s)
that sets the speed of a single car to the value in s.
Thus if c1 is a Car instance
and c2 is a Car instance, they both can be given their own speeds, by calling
c1.setSpeed(33.3) and c2.setSpeed(14.7).
Member functions can only be applied to
instances of a class not to classes.
In this chapter you can look briefly at Sec. 6.1 on structures,
but focus on Sec. 6.2. We will not discuss constructors (Sec. 6.3) for now and
they will not be on the Midterm. They will be on the Final and you may find them
useful in your labs. You must know how to write an ADT (which you all seem to know)
but most importantly how to define and use member functions. THIS IS IMPORTANT.
KNOW HOW TO CORRECTLY DEFINE AND USE MEMBER FUNCTIONS. This will include the
important operation of defining a variable of the appropriate type, e.g., Car c1;
Then you can use dot notation with the instance. Another point to understand well
is this: The member variables of a class are available to all member functions
just as if they had been declared as local variables; they should never be redeclared
in a member function and no member function should have formal arguments with the
same names as member variables.
-
Most of you appear to know the basic flow-of-control statements in Chapter 7. I
will assume that you know the basics but not test you on messy examples.
We'll use them in simple examples, or I may give the code to you and you'll
simply have to understand how it works.
-
Chapter 8 material will not be on the Midterm.
-
The final topic is arrays, portions of Chapter 9. These are very important
constructs, so you must know the basics of arrays. Review my discussion of
Quiz #2 on these matters for starters. You need to know how to declare them
and access them. And furthermore, know how to define functions and classes
that use arrays and how to use them as arguments and return them from
functions.
-
Pointers: Nothing on pointers on the Midterm. But definitely on the Final.
[Boy, I'm glad I can type fast. You never would have gotten all this if
I couldn't! After some preparation, it took me an hour to write.
If you don't touch type, learn. It helps.]