#include <iostream.h> #include <assert.h> template <class T, int i> class tstack { private: T data[i]; int items; public: tstack(); void push(T item); T pop(void); void print(void); }; // Constructor template <class T, int i> tstack<T, i>::tstack(void) { items = 0; } template <class T, int i> void tstack<T, i>::push(T item) { assert(items < i); data[items++] = item; } template <class T, int i> T tstack<T, i>::pop(void) { assert(items > 0); return (data[--items]); } main() { tstack <int, 20> int_stack; tstack <double, 10> double_stack; int_stack.push(7); int_stack.push(45); double_stack.push(3.14); double_stack.push(1.41); cout << int_stack.pop() << "\n"; cout << int_stack.pop() << "\n"; cout << double_stack.pop() << "\n"; cout << double_stack.pop() << "\n"; }