Lab 11: Instructor's Notes


This exercise introduces the student to enumeration types in C++. The exercise consists of eight parts. Note that versions of GNU C++ (g++) prior to version 2.8.0 are not sufficiently ANSI-compliant as to permit the completion of parts 4-8. If you are using a version of g++ older than 2.8.0, you should upgrade to the lastest version, as it is much more ANSI-compliant than the older versions.

In the first seven parts, the students develop a Gender enumeration. To illustate what they are to do, the exercise builds a Season enumeration as a running example.

In addition to the enumeration itself, students implement the input, output, prefix increment, postfix increment, prefix decrement, and postfix decrement operations for their new type. The students will use the files driver.cpp, Gender.h, Gender.cpp, Gender.doc, and Makefile in this part of the exercise.

Since defining these operations is a mechanical process for every enumeration one is likely to declare, we have provided a code-generating program enumGenerator.cpp that, given the desired name for an enumeration and an input file of enumerators (one per line), will generate the complete header, implementation and documentation files for such an enumeration. Students use this tool to build a Day enumeration in the final part of the exercise, introducing students to the power of an automatic code-generating tool. We also provide a simple driver program named dayTester.cpp that students can use to test their Day enumeration.

As always, if you wish to avoid network contention, save local copies of the required files ahead of time and instruct your students on how to access them.


Back to This Lab's Home Page

Forward to the Prelab Questions


Copyright 1998 by Joel C. Adams. All rights reserved.