#include<iostream>
using namespace std;
class Stackexception{
	char* why;
	public:
	Stackexception(char* p):why(p){}
	char* reason()
	{
		return why;
	}
};
template<typename T>
class Stack{
	T* data;
	int size;
	public:
	Stack(int s)
	{
		size=s;
		data=new T[size+1];
	}
	~Stack()
	{
		delete[] data;
	}	
	void fix(T a,int ba)
	{
		if(ba<0 || ba>=size)throw Stackexception("Invaild argument for Stack<T>::push(T,int).");
		data[ba]=a;
	}
	T get(int i)
	{
		if(i<0 || i>=size)throw Stackexception("Invaild argument for Stack<T>::get(int).");
		return data[i];
	}
};
int main()
{
	Stack<int> s1(100);
	try
	{
	for(int i=0;i<100;i++){
		s1.fix(i,i);
		cout<<s1.get(i)<<endl;
	}
	s1.fix(100000,1000);
	}
	catch(Stackexception& a)
	{
		cout<<a.reason()<<endl;
	}
}
894| 186| 950| 689| 274| 124| 492| 823| 734| 397|