This website is preserved for historical and scholarly reference and is no longer actively maintained.
Assignment #1
Due Friday, January 29 at 8:00 a.m..
Individual programming assignments will be accepted up to two calendar days after the program was due. There will be penalty points deducted as follows.
turned in by 8:00 a.m. Monday: 20 points deducted
turned in by 8:00 a.m. Tuesday: 40 points (total) deducted
not accepted after 8:00 a.m. Tuesday
***** IMPORTANT *****
To use the code from the Weiss text (2nd Edition) you may:
- Comment out the throw statements.
- Append the implementation to the interface (.h file). That is, you will not have a separate .cpp file for Stack. Include all the implementation after the definition in the .h file. -- Sorry about that. The compiler we are using will not yet support the separate implementation file for templates.
Alternative methods of avoiding problems with templates will be explained in class.
***** ASSIGNMENT *****
Write a copy constructor for the linked list implementation of a stack given in the Weiss text.
You will need a printStack function that is part of your user program. You will use the printStack function to test whether or not the copy constructor works. The printStack function must not invoke the copy constructor and must not result in the destruction of the stack it is printing.
Your user program should perform the following tests to determine whether or not the copy constructor is working correctly:
- Copy an empty stack and call printStack
- Copy a stack containing one element and make 2 consecutive calls to printStack.
- Copy a stack containing two elements and make 2 consecutive calls to printStack.
- Copy a stack containing some number of elements greater than 5 and make 2 consecutive calls to printStack.
Using the handin command, turn in your user program, Stack.h, and Stack.cpp. Programs that do not compile will receive very little credit.