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.
As usual, your students will need to create a project
to coordinate the compilation and linking.
-
Part 2 extends part 1, by teaching students to overload the
insertion and extraction operators for Fraction objects.
The needed file is
pierre2.cpp,
plus the Fraction library files used in Part 1.
Your students should create a separate project in their workspaces to
handle the compilation and linking of pierre2.cpp
and the Fraction library files.
If you do not wish to have your students learn about
overloading the insertion and extraction operators,
feel free to skip Part 2.
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.