



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




template
(a) Write a member function template
(c) A stack of integers aStack has the following private data: top: 4 items: 8 0 0 4 7 10 -34323 0 67823 - What is the output of the following code? int x; while (!aStack.isEmpty()){ aStack.pop(x); cout << x << " "; } Hint: Recall that top is the array index of the top of the stack.
(a) aQueue.dequeue(st) Answer: (b) aQueue.enqueue("nail") Answer: (c) aQueue.getFront(st) Answer: (d) aQueue.enqueue(st) Answer: (e) aQueue.dequeue() Answer:
7 8 โ 3 14 5
What is the output to the screen of the following code?
int x; while (!bStack.isEmpty()){ bStack.pop(x); if (x>0 && !bStack.isEmpty()) bStack.pop(); cout << x << endl;
(b) template
(b) aQueue.enqueue("nail") Answer: house, pig, car, hill, nail (c) aQueue.getFront(st) Answer: house, pig, car, hill, nail (d) aQueue.enqueue(st) Answer: house, pig, car, hill, nail, house (e) aQueue.dequeue() Answer: pig, car, hill, nail, house