// #include <iostream>
// using namespace std;
//
// deliberately omitted 'template <typename T>' 
//     for just demonstrating the template-token of ULS.
//
class TmplStack {
	T     *stk_array;
	int    stk_siz, top;

 public:

	TmplStack(int stack_size) {
		if (stack_size <= 0) stack_size = 1;
		stk_array = new T[stack_size];
		stk_siz = stack_size;
		top = 0;
	}

	~TmplStack() {
		delete[] stk_array;
	}

	bool isEmpty() {
		return top == 0 ? true : false;
	}

	bool isFull() {
		return top == stk_siz ? true : false;
	}

	void push(const T& elmt) {
		if (isFull()) {
			cout << "stack full: fail to push!\n";
			return;
		}
		stk_array[top++] = elmt;
	}

	T pop() {
		if (isEmpty()) {
			cout << "stack empty: fail to pop!\n";
		} else {
			--top;
		}
		return stk_array[top];
	}
};
