📄 stackl.cpp
字号:
// *********************************************************// Implementation file StackL.cpp for the ADT stack.// ADT list implementation.// *********************************************************#include "StackL.h" // header fileStack::Stack(){} // end default constructorStack::Stack(const Stack& aStack): aList(aStack.aList){} // end copy constructorStack::~Stack(){} // end destructorbool Stack::isEmpty() const{ return aList.isEmpty();} // end isEmptyvoid Stack::push(StackItemType newItem) throw(StackException){ try { aList.insert(1, newItem); } // end try catch (ListException e) { throw StackException("StackException: cannot push item"); } // end catch} // end pushvoid Stack::pop() throw(StackException){ try { aList.remove(1); } // end try catch (ListIndexOutOfRangeException e) { throw StackException("StackException: stack empty on pop"); } // end catch} // end popvoid Stack::pop(StackItemType& stackTop) throw(StackException){ try { aList.retrieve(1, stackTop); aList.remove(1); } // end try catch (ListIndexOutOfRangeException e) { throw StackException("StackException: stack empty on pop"); } // end catch} // end popvoid Stack::getTop(StackItemType& stackTop) const throw(StackException){ try { aList.retrieve(1, stackTop); } // end try catch (ListIndexOutOfRangeException e) { throw StackException("StackException: stack empty on getTop"); } // end catch} // end getTop// End of implementation file.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -