pointer to a Class initialization question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • 2005

    #1

    pointer to a Class initialization question

    Hi

    I have two classes ( CNode & CAll ) and I created 2 objects for the
    latter class, CAll.

    CAll All_A, All_B;

    class CAll {
    public:

    ------

    private:


    CNode *m_pTop; // pointer to top of Allay (stack)
    int mSize; // number of nodes in Allay (stack)
    int mMaxSize; //max number of nodes in Allay (stack)
    };

    class CNode {
    public:

    ------

    private:
    int m_ticketNum; // ticket number of car
    CNode *m_pNext; // pointer to next node in stack
    };

    I have a pointer to All_B called *pB which I am expected to pass it to
    a function.

    I have trouble with *pB.

    I did the following in the code:

    CAll All_A, All_B; // initialize 2 objs All_A & All_B;
    All_B pB;

    But the above line is causing syntax error.

    What is that I am missing?

    The spec states that pB is a pointer to All_B.

    Thanks

  • Thomas Tutone

    #2
    Re: pointer to a Class initialization question

    2005 wrote:
    I have two classes ( CNode & CAll ) and I created 2 objects for the
    latter class, CAll.
    >
    CAll All_A, All_B;
    >
    class CAll {
    public:
    >
    ------
    >
    private:
    >
    >
    CNode *m_pTop; // pointer to top of Allay (stack)
    int mSize; // number of nodes in Allay (stack)
    int mMaxSize; //max number of nodes in Allay (stack)
    };
    >
    class CNode {
    public:
    >
    ------
    >
    private:
    int m_ticketNum; // ticket number of car
    CNode *m_pNext; // pointer to next node in stack
    };
    >
    I have a pointer to All_B called *pB which I am expected to pass it to
    a function.
    >
    I have trouble with *pB.
    >
    I did the following in the code:
    >
    CAll All_A, All_B; // initialize 2 objs All_A & All_B;
    All_B pB;
    If pB is supposed to be a pointer to All_B, then I assume the above
    line should be:

    CAll* pB = &All_B;

    Best regards,

    Tom

    Comment

    Working...