//CIS 610-251: Queue and LinkList //Due OCt 14,1999 //Assignment # 4, Question # 2. //Object: Stack of Queue #include #include "queue.h" class Stack { private: Queue * data; //data value in stack unsigned sp; // Stack Pointer unsigned spMax; //Max Stack Pointer Value; public: Stack(); void push(Queue); Queue pop() ; Queue StackTop(); bool isEmpty(void); }; //Constructor Stack::Stack() { data=new Queue[256]; //init data as an array of 256 integer sp=0; //Stack initialized spMax=255; Queue q;q.Insert(0); data[0]=q; } //Add an element to Stack and increment the SP. void Stack::push(Queue item) { if (sp0) return data[sp--]; else return q; } //return how many elements in Stack. Queue Stack::StackTop() { return data[sp]; } bool Stack::isEmpty() { return (!sp)? true : false; } main() { Stack s; Queue q,q2; q.Insert(9); q.Insert(10); s.push(q); q2=s.pop(); cout << q2.Remove(); return 0; }