/*
* stack demo, evaluation for arithmetic expression
* Time-stamp: <2011-08-24 15:17:31 root>
*
* snallie@tom.com
*/
#include <iostream>
using namespace std;
template < class T > class stk {
#define SIZE 100
public:
stk():sp(0) {
stk_base = new T[SIZE];
stk_bottom = stk_base + SIZE - 1;
sp = SIZE;
}
~stk() {
delete stk_base;
}
void push(T a) {
if (!stk_full())
stk_base[--sp] = a;
}
T pop() {
if (!stk_empty())
return stk_base[sp++];
}
bool stk_empty() {
return (sp == SIZE);
}
bool stk_full() {
return (sp == 0);
}
<
* stack demo, evaluation for arithmetic expression
* Time-stamp: <2011-08-24 15:17:31 root>
*
* snallie@tom.com
*/
#include <iostream>
using namespace std;
template < class T > class stk {
#define SIZE 100
public:
stk():sp(0) {
stk_base = new T[SIZE];
stk_bottom = stk_base + SIZE - 1;
sp = SIZE;
}
~stk() {
delete stk_base;
}
void push(T a) {
if (!stk_full())
stk_base[--sp] = a;
}
T pop() {
if (!stk_empty())
return stk_base[sp++];
}
bool stk_empty() {
return (sp == SIZE);
}
bool stk_full() {
return (sp == 0);
}
<