c++使用嵌套类实现堆栈

class CStack
{
 private:
    Struct CItem
    {
        CBox* pBox;
        CItem* pNext;
       
        CItem(CBox* pB,CItem* pN):pBox(pB),pNext(pN){}
    };
 public:
     void Push(CBox* pBox)
    {
     ptop = new CItem(pBox,pTop);
    }
    CBox* Pop()
    {
        if(pTop == 0)
            return 0;
       
        CBox* pBox = pTop->pBox;
        CItem* pTemp = pTop;
        pTop = pTop->Next;
        delete pTemp;
        retuen pBox;
    }
}

 

你可能感兴趣的:(c++使用嵌套类实现堆栈)