Create a Stack class. Use a typedef to define an Entry_type data type (see page 58). Your Stack class should work with any datatype by changing the typedef. Make int the default data type. Implement your Stack as a static array of size 100. Include the standard operations on your stack: push, pop, top, empty, full. Initialize your stack in the constructor. If you want you may use an enumerated class to return error conditions: stack_overflow, stack_underflow, success. You do not have to follow this model, you may instead use C++ exception handling. In either case, you must implement error checking. Use const wherever appropriate.
Add to your stack the following:
# pop_top: removes the top entry from the Stack and returns its value as the output parameter t.
# clear: deletes all entries and leaves an empty Stack.
# size: leaves the Stack unchanged and returns a count of the number of entries in the Stack.
I know this is too long answer, any advise on how should i construct my stack.h file? I have the basic idea, but in an experienced point of view, i wonder how they would approach this problem. If you can please elaborate with code example. I will not cut and paste your code, my purpose here it to learn from other people's point of view on how to approach / design stack header files. In real world, we are not to change an stack.h files .. it's like reinventing the wheel. But somehow we are to create a stack.h. I guess for us to see how it really works.
Thanks.
- Mike
