#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 ; Stack y ; int a; double b; bool h; int i; for (i=1; i<= 15; i++) { x.Push(i); cout<< "x.Push " << i << endl;} for (i=1; i<= 15; i++) { if ( x.Isempty()) break; h = x.Pop(a); h = y.Push(a+0.5); cout<< "y.Push " << a+0.5 << endl; } for (i=1; i<= 15; i++) if ( y.Isempty() ) return 0; else {h=y.Pop(b); cout << b << endl;} }