#include "PilhaLE.h" //----------------------------------- // Constructor method //----------------------------------- PilhaLE::PilhaLE() { top_ = 0; } //----------------------------------- // Destructor method //----------------------------------- PilhaLE::~PilhaLE(void) { while ( !isEmpty() ) { pop(); } } //----------------------------------- // Class methods //----------------------------------- int PilhaLE::isEmpty() { return (top_ == 0) ? 1 : 0; } int PilhaLE::isFull() { return 0; } void PilhaLE::push(int n) { top_ = new elemPilha(top_, n); } int PilhaLE::pop() { int val = -1; if( ! isEmpty() ) { elemPilha *ep = top_; // get a pointer to the last inserted element !!! val = top_->value_; // or val = ep->value_; top_ = top_->next_; // or top_ = ep->next_; delete ep; } return val; } int PilhaLE::top() { return top_->value_; // (*top_).value_ }