Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > pointer to a Class initialization question

Reply
Thread Tools

pointer to a Class initialization question

 
 
2005
Guest
Posts: n/a
 
      10-27-2006
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

 
Reply With Quote
 
 
 
 
Thomas Tutone
Guest
Posts: n/a
 
      10-27-2006
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Initialization of a const matrix implemented as pointer-to-pointer Andrea Taverna (Tavs) C Programming 17 09-24-2008 12:28 PM
Proper Initialization of Pointer to Pointer bwaichu@yahoo.com C Programming 11 02-09-2008 05:33 PM
Pointer to class equals pointer to base class Alberto Luaces C++ 6 06-19-2006 06:16 PM
Pointer-to-pointer-to-pointer question masood.iqbal@lycos.com C Programming 10 02-04-2005 02:57 AM
[RTTI] cast base class pointer to <templated> derived class pointer tirath C++ 3 10-12-2003 01:44 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57