By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,961 Members | 1,320 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,961 IT Pros & Developers. It's quick & easy.

tracking handle

P: n/a
Hi,

I have a question regarding a reference to tracking handle.

In older C++ if I write below code would add new node to the linked
list.

Object* o = linkList->FirstNode;
while ( o != null ) {
o = o->nextNode;
}
o = newNode;

However in Visual C++ 2005.NET, I wrote the following code and it does
not add a new node to linked list.

Object^ o = linkedList->FirstNode;
while ( o != nullptr ) {
o = o->nextNode;
}
o = newNode;

Is there a way to correct this. Am I missing something?

Regards

Apr 22 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi,

As you have it, the C/C++ version would not work either. After the while
loop, o is null and has no relation to the original list. The following
would probably do what you want

while ( o->nextNode != null )
{
o = o->nextNode;
}
o->nextNode = newNode;

Hope this helps

--
Chris Taylor
http://dotnetjunkies.com/weblog/chris.taylor
"manjub" <ms****@gmail.comwrote in message
news:11*********************@n59g2000hsh.googlegro ups.com...
Hi,

I have a question regarding a reference to tracking handle.

In older C++ if I write below code would add new node to the linked
list.

Object* o = linkList->FirstNode;
while ( o != null ) {
o = o->nextNode;
}
o = newNode;

However in Visual C++ 2005.NET, I wrote the following code and it does
not add a new node to linked list.

Object^ o = linkedList->FirstNode;
while ( o != nullptr ) {
o = o->nextNode;
}
o = newNode;

Is there a way to correct this. Am I missing something?

Regards
Apr 22 '07 #2

P: n/a
Thanks a lot for your help. It seems to work.

On Apr 22, 3:06 am, "Chris Taylor" <chris_taylor...@hotmail.com>
wrote:
Hi,

As you have it, the C/C++ version would not work either. After the while
loop, o is null and has no relation to the original list. The following
would probably do what you want

while ( o->nextNode != null )
{
o = o->nextNode;}

o->nextNode = newNode;

Hope this helps

--
Chris Taylorhttp://dotnetjunkies.com/weblog/chris.taylor

"manjub" <msb...@gmail.comwrote in message

news:11*********************@n59g2000hsh.googlegro ups.com...
Hi,
I have a question regarding a reference to tracking handle.
In older C++ if I write below code would add new node to the linked
list.
Object* o = linkList->FirstNode;
while ( o != null ) {
o = o->nextNode;
}
o = newNode;
However in Visual C++ 2005.NET, I wrote the following code and it does
not add a new node to linked list.
Object^ o = linkedList->FirstNode;
while ( o != nullptr ) {
o = o->nextNode;
}
o = newNode;
Is there a way to correct this. Am I missing something?
Regards

Apr 23 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.