Listing 2
template<typename T> class ConcreteStack : AbstractStack { public: ~ConcreteStack() { while (!IsEmpty()) Pop(); } void Push(std::auto_ptr<Item> x) { m.push_back(x.release()); } std::auto_ptr<Item> Pop() { std::auto_ptr<Item> x = m.top(); m.pop_back(); return m; } bool IsEmpty() { return m.IsEmpty(); } private: std::vector<Item*> m; };