#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,j; for (i=1; i<= 5; i++) { int *y = new int [3]; for (j = 0; j<= 2; j++) y[j]=j+i*4; x.Push(y); cout<< "x.Push " << i << endl;} for (i=1; i<= 15; i++) { int *y; if ( x.Isempty()) break; h = x.Pop(y); cout << *y << " " << *(y+1) << " " << *(y+2) << endl; cout<< "x.Pop " << endl; } }