Assignment 1

CS 152
due February 24, 2000
100 points

Do the assignment described in the handout entitled "The programming assigment, CS 152, Spring 2000", using either C or C++. The test cases are given in the file a1test.cpp, available from the class web site. You should not make unnecessary changes to these files, and should link them to your other files. The #include directives in a1test.cpp assume that you are using a modern version of C++, so one example of a necessary change would be modifying them if you are using an earlier version. Another example would be modifying the file to work with C rather than C++, e.g., by calling a function new_environment() rather than calling new environment(), and similarly for delete.

You are responsible for constructing the appropriate header file(s) so that the test file may be compiled. The parameter types and the return types of the functions it calls are described in the handout mentioned above. However some inspection of the test file may be necessary. Also, the type of the argument to add_binding should be of a special filler type that takes on integer values; you may use typedef to define this type.

You should reclaim storage. Note that the test code only explicitly calls delete for environments -- deletions for objects of other types should take place inside other methods (or functions, in C). Some C++ compilers have a switch to enable rejection of any code that is not C code. Consider using this feature if you are writing C code and have a C++ compiler. I will be using such a feature in grading the C versions of this assignment, and I may deduct for C++ features used in C. In particular, do not use the // notation for comments, or use a .cpp extension, if you are doing the assignment in C. Expect deductions if you do either of these.

For C++, I recommend a modern, ANSI-compliant implementation, and in particular the use of templates and libraries for container classes, which are not available in older implementations. If you are using the Microsoft Visual implementation, you may make your project a console application if you want.