//* Stack implementation variations that are not a part of our official Stack template *

//* top() *

// simple but inefficient for large data structures version of top() template <typename T> inline T Stack<T>::top() const { return myArray[myTop]; } // OR non-const return reference top() allows to alter the top of the stack template <typename T> inline T& Stack<T>::top() { return myArray[myTop]; } // AND we still need a const method in case a stack was passed to us by const reference template <typename T> inline const T& Stack<T>::top() const { return myArray[myTop]; }

//* pop() *

// classic pop() template <typename T> void Stack<T>::pop() { myTop--; } // alternative solution for pop() seen frequently template <typename T> const T& Stack<T>::pop() { return(myArr[myTop--]); } // or in case you are afraid that the internal array will shrink or be gone template <typename T> T Stack<T>::pop() { return(myArr[myTop--]); }