// @topic T00530 Project 1/Part 1, Stack of integers // @brief IntStack class implementation #include <iostream> // needed for std::cerr #include "IntStack.h" void IntStack::reset() { m_sp = 0; } void IntStack::push( int element ) { // before: // [] [] [] [] [] [] // | // m_sp // // after: // [] [] [e] [] [] [] // | // m_sp // m_array[ m_sp ] = element; ++m_sp; } int IntStack::top() { if ( m_sp == 0 ) { std::cerr << "stack is empty!"; return -1; } return m_array[ m_sp - 1 ]; } void IntStack::pop() { // Not implemented } unsigned int IntStack::size() { return m_sp; }