www.pudn.com > metrix3.zip > Stack.h
#if !defined(AFX_STACK_H__75314E61_4BBF_11D5_9DFE_5254AB1C303A__INCLUDED_) #define AFX_STACK_H__75314E61_4BBF_11D5_9DFE_5254AB1C303A__INCLUDED_ #includetemplate class CStack:public CList { public: CStack(); ~CStack(); void Push(T data); bool Pop(T & data); T GetTop(); }; template CStack ::CStack() { } template CStack ::~CStack() { } template void CStack ::Push(T data) { AddHead(data); } template bool CStack ::Pop(T & data) { if(GetCount()==0) return false; POSITION pos=GetHeadPosition(); data=GetAt(pos); RemoveAt(pos); return true; } template T CStack ::GetTop() { return GetHead(); } #endif