#include #include "array_stack.h" using namespace std; int Stac::MAXVAL = 100; Stac::Stac(){ _sp = 0; _val = new double*[MAXVAL]; } Stac::Stac(int max){ MAXVAL = max; _sp = 0; _val = new double*[MAXVAL]; } Stac::~Stac(){ for(int i = 0; i < _sp; i++) delete[] _val[i]; delete[] _val; } // push: push str onto string stack void Stac::push(double *a){ if(_sp < MAXVAL) _val[_sp++] = a; else cerr << "error: stack full, can't push\n"; } // pop: pop and return top value from stack double *Stac::pop(void){ if(_sp > 0) return _val[--_sp]; else{ cerr << "error: stack empty\n"; return 0; } } void Stac::maxval(void){ cout << "value of MAXVAL: " << MAXVAL << endl; }