Lab 10: Instructor's Notes
This exercise leads students through the creation of a
Fraction class by which fraction objects can be represented.
The exercise consists of two parts:
-
Part 1 builds the basic Fraction class,
using only function members.
The required files are
pierre1.cpp,
Fraction.h,
Fraction.cpp, and
Fraction.doc.
In addition to constructors, extractors, and I/O member functions,
students learn to overload the multiplication operator (*)
using a function member of the Fraction class.
-
Part 2 extends part 1, by teaching students to overload the
insertion and extraction operators for Fraction objects.
The needed file is
pierre2.cpp.
If you do not wish to have your students learn about
overloading the insertion and extraction operators,
feel free to skip Part 2.
A Makefile
is provided to facilitate the translation of these files.
It contains both pierre1 and pierre2
as targets: to translate pierre1.cpp, simply use make;
to translate pierre2.cpp, use make pierre2.
As usual, if you wish to avoid network delays,
save copies of these files ahead of time
refer your students to your local copies.
Back to This Lab's Home Page
Forward to the Prelab Questions
Copyright 1998 by
Joel C. Adams. All rights reserved.