[ create a new paste ] login | about

Link: http://codepad.org/C15VzSKT    [ raw code | output | fork ]

C++, pasted on Mar 4:
    #define MAXSIZE 200

    class CarNode {
        public:
            CarNode() {m_pNext = NULL; m_ticketNum = 0; }
            ~CarNode();
            CarNode(CarNode &) {m_pNext = NULL; m_ticketNum = 0;}
            void SetNext(CarNode* p){m_pNext=p;}
            void SetTicketNum(int tN){m_ticketNum=tN;}
            CarNode *GetNext(void){return(m_pNext);}
            int GetTicketNum(void){return(m_ticketNum);}
        private:
            int m_ticketNum;
            CarNode *m_pNext;
    };

    class CAlley {
        public:
            CAlley () { m_pTop = NULL; mSize = 0; mMaxSize =MAXSIZE; }
            ~CAlley () {}
            CAlley (CAlley &){m_pTop = NULL; mSize = 0; mMaxSize =MAXSIZE; }
            int Park(int);
            void Retrieve(int,CAlley *);
            void Terminate();
            void Display();
            void Push(CarNode *p) { m_pTop = p;}

        private:
            void SetTop(CarNode *p){m_pTop=p;}
            bool Empty(){return ((mSize==0) ? true : false);}
            bool Full() {return ((mSize==MAXSIZE) ? true : false);}
            CarNode * Pop();
            CarNode *m_pTop;
            int mSize;
            int mMaxSize;
    };

    void CAlley::Display()
    {
        cout << "Alley A:\t";
        CarNode * pCurr = m_pTop;
        while (pCurr != NULL)
        {
            cout << pCurr->GetTicketNum();
            if(pCurr->GetNext()!=NULL)
                cout<< '\t';
            pCurr=pCurr->GetNext();
        }
        cout << '\n';
    }

    int main() {
        CAlley* c = new CAlley();
        CarNode * pCurr = new CarNode();
        pCurr->SetTicketNum(5);
        pCurr->SetNext(new CarNode());
        pCurr->GetNext()->SetTicketNum(3);
        c->Push(pCurr);
        c->Display();

        return 0;
    }


Output:
1
Alley A:	5	3


Create a new paste based on this one


Comments: