tracking handle

  • Thread starter Thread starter manjub
  • Start date Start date
M

manjub

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
 
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
 
Thanks a lot for your help. It seems to work.

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
 
Back
Top