//mystk8.h --- CopyLeft by tsaiwn@csie.nctu.edu.tw // implement a stack using a via Inheritance method // 注意這版本是用 Inheritance 的方式, 不是用 contains 的方式 #include using namespace std; template class MyStack: list { public: void push(const T& y) { MyStack::push_front(y); } T top( ) { return MyStack::front( ); } void pop( ) { MyStack::pop_front( ); } bool empty( ) { return MyStack::begin() == MyStack::end(); } };