#include using namespace std; template < class T > class Stack { private: enum {MAX = 10}; T items[MAX]; int top; public: Stack(); bool Isempty(); bool Isfull(); bool Push(const T & item); bool Pop(T & item); }; template Stack::Stack() { top =0;} template bool Stack::Isempty() { return top == 0;} template bool Stack::Isfull() { return top == MAX;} template bool Stack::Push(const T & item) { if (top < MAX) { items[top++] = item; return true; } else { return false;} } template bool Stack::Pop(T & item) { if (top > 0) { item = items[--top]; return true; } else { return false;} } int main() { cout << endl; Stack *> x ; int a,i,j,k; double b; bool h; for (i=1; i<= 5; i++) { Stack *y = new Stack; for (j=1; j<= 4; j++) { h=y->Push(i+j); cout<< "Push " << i << " " << j << " " << i+j << endl; } h=x.Push(y); } for (i=1; i<= 5; i++) { Stack *y; h=x.Pop(y); for (j=1; j<= 4; j++) { h=y->Pop(k); cout<< "Pop " << i << " " << j << " " << k << endl; } } }