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