//DataType.h
template <class tObj>
class stack
{
private:
tObj aStack[100];
int iPnt;
public:
stack()
{
iPnt=0;
}
void push(tObj obj);
tObj top();
tObj pop();
int empty();
int num();
};
template <class tObj>
void stack<tObj>::push(tObj obj)
{
if (iPnt<100)
{
aStack[iPnt++]=obj;
}
}
template <class tObj>
tObj stack<tObj>::pop()
{
if (iPnt!=0)
{
return aStack[--iPnt];
}
}
template <class tObj>
tObj stack<tObj>::top()
{
if (iPnt!=0)
{
return aStack[iPnt-1];
}
}
template <class tObj>
int stack<tObj>::empty()
{
return (iPnt==0);
}
template <class tObj>
int stack<tObj>::num()
{
return iPnt;
}
int vs(char cOperator)
{
if ((cOperator=='+') || (cOperator=='-'))
{
return 1;
}
else if ((cOperator=='*') || (cOperator=='/'))
{
return 2;
}
else return 0;
}
int vs()
{
return 0;
}