Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <cstdlib>
- #include <iostream>
- #include "stack.h"
- using namespace std;
- template <class Type>
- void addItems(Stack<Type> stack);
- template <class Type>
- void removeItems(Stack<Type> stack);
- int main() {
- int max;
- int intTmp;
- Stack<int> intStack = Stack<int>();
- max = intStack.getMax();
- cout << "Max = " << max << endl;
- addItems(intStack); //---- ???????
- cout << endl << "Stack is full! Let's pop() everything:" << endl << endl;
- removeItems(intStack); //--- ???????
- system("PAUSE");
- return 0;
- }
- template <class Type>
- void addItems(Stack<Type> stack) {
- Type tmp;
- while (!stack.isFull()) {
- cout << "Give a number: ";
- cin >> intTmp;
- stack.push(intTmp);
- cout << "-----" << endl;
- cout << "How many items?: " << stack.getTop() << "/" << stack.getMax() << endl;
- stack.showItems();
- cout << "==========" << endl;
- }
- }
- template <class Type>
- void removeItems(Stack<Type> stack) {
- Type tmp;
- cout << "A? " << stack.getTop() << endl;
- while (!stack.isEmpty()) {
- stack.pop(intTmp);
- cout << "Popped(): " << intTmp << endl;
- cout << "-----" << endl;
- cout << "How many items?: " << stack.getTop() << "/" << stack.getMax() << endl;
- stack.showItems();
- cout << "==========" << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement