#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(count() > 0, "Stack underflow!"); return (*this)[--_sp]; } TObject& TStack::peek(int depth) const { CHECK(depth > _sp, "Stack underflow!"); return (*this)[_sp-depth-1]; }