CS Logo

Homework 7 (Last Homework for the Semester!)

 

This homework is due by next Monday at Midnight.

Implement a stack class and a queue class. Use the code I provided in the solution to homework 6 to implement pop and push.

For each class pop and push will be public member functions (methods). Your stack and queue only has to store integers.

The top and bottom counters and the array of integers will all be private data members. This is different that in the homework 6 solution where the top and bottom counters existed in the main function.

Write a driver program to instantiate your classes, read integers from the user, and store and retrieve integers using your queue and stack objects.

Set the size of the stack or queue by passing the size specified by the user into the object using the constructor. Your constructor prototypes will be

Stack( int ); and Queue( int );

The function prototype for push must be void push( int );

The function prototype for pop must be int pop();

Your solution will consist of 6 files.

Stack.cpp and Stack.h

Queue.cpp and Queue.h

driver.cpp and the Makefile

I will assign 40 points each to the stack and queue classes and 20 to the driver program and Makefile.