I am having trouble understanding a question. The question asks first to write a C++ class to represent a stack of integers. Done. Here are my prototypes:
class Stack{
private:
int top;
int item[100];
public:
Stack() {top = -1;}
~Stack();
void push(int x) {item[++top] = x;}
int pop() {return item[top--];}
int empty(int top);
};
The second part of the question says "Using the stack for storage purposes, write a C++ class to represent a queue of integers". My queue is as follows:
class Queue{
private:
int * data;
int beginning, end, itemCount;
public:
Queue(int maxSize = 100);
Queue(Queue &OtherQueue);
~Queue();
void enqueue(int x);
void dequeue();
int amount();
};
I don't understand how I am meant to use a stack for storage purposes for a queue.