Step 1: Get the files

The only file you need for this lab is exceptions.cpp. This file contains the main() and the IntStack class. If you've ssh’ed into the GL servers, you can copy the file to your working directory with the command:

    cp /afs/ .

The IntStack class works as follows. When constructed, it allocates a vector of a specified size. This size will not change and limits the number of items that can go in the stack. IntStack also has two functions that are usually included with stacks: push() and pop(). push() adds an item to the stack; this can cause an error if the stack doesn't have any more room. pop() removes the most recently added item; this can cause an error if the stack is empty. The stack keeps track of the top with an unsigned integer called cur_index. This number stores the index that will be pushed onto next. For example, if cur_index is 0, the stack is empty and the next pushed item will be placed in index 0 of the vector.

The main() function includes three tests that specifically trigger each error case.