CS233V C++ Programming
Assignment #9
Exercises
9.1, 9.3, 9.4, 9.8
Programming
Implement
a class IntegerStack in two ways:
-
As a derived class of class Array
-
Based on composition using class Array.
In both cases you must provide public member void
push(int x) that pushes x onto the stack, int pop() that
removes the item on top of the stack and returns it, bool isEmpty()
that returns true if the stack is empty, and a constructor IntegerStack(int
size = 10) that creates a stack with capacity size. You may
also want to provide some operator overloads, e.g., assignment. This can
be done easily by making use of the Array overloads.
Be careful that your implementation does not allow any inappropriate actions,
e.g., accessing data other than at the top.
Write driver programs to test both implementations.