#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; double b; bool h; int i; for (i=1; i<= 15; i++) { int* y = new int; *y = i; h=x.Push(y); cout<< "x.Push " << i << endl; if (!h) delete y;} for (i=1; i<= 15; i++) { int* y; if ( x.Isempty()) break; h = x.Pop(y); cout<< "x.Pop " << *y << endl; delete y; } }