// mystk2.cpp -- implementation of the stack (by tsaiwn@csie.nctu.edu.tw) #include "mystk2.h" void MyStack::push(int x) { stkptr++; data[stkptr] = x; } int MyStack :: top(void) { return data[stkptr]; } //Actually, pop( ) function is a void function in C++ STL void MyStack ::pop(void) { if(stkptr> -1) --stkptr; }