template <class T> class Stack
{
public:
	class Underflow {};
	class Overflow {};

	virtual void push (T) = 0;
	virtual T pop() = 0;
};

template <class T> class ArrayStack :
	public Stack<T>
{
	T* v;
	int max_size;
	int top;
public:
	ArrayStack (int s);
	~ArrayStack ();

	void push (T);
	T pop();
};

template <class T> ArrayStack<T>::ArrayStack (int s)
{
	v = new T (s);
	max_size = s;
	top = 0;
}

template <class T> ArrayStack<T>::~ArrayStack ()
{
	delete [] v;
}

template <class T> void ArrayStack<T>::push (T e)
{
	//if (top >= max_size) throw Stack<T>::Overflow();
	v[++top] = e;

}

template <class T> T ArrayStack<T>::pop()
{
	//if (top <= 0) throw Stack<T>::Underflow();
	return v[top--];
}

int main()
{
	Stack<int> *i_s = new ArrayStack<int> (20);
	i_s->push (20); i_s->pop();
	delete (i_s);
	
	/*
	Stack<double> *d_s = new ArrayStack<double> (20);
	d_s->push (2.4); d_s->pop();
	delete (d_s);
	*/
}


