#include TStack::TStack(int size) : TArray(size), _sp(0) {} void TStack::push(const TObject& o) { add(o, _sp++); } void TStack::push(TObject* o) { add(o, _sp++); } TObject& TStack::pop() { CHECK(_sp > 0, "Stack underflow!"); return (*this)[--_sp]; } TObject& TStack::peek(int depth) const { CHECKD(depth >= 0 && depth < _sp, "Stack depth error: ", depth); return (*this)[_sp-depth-1]; }