difficult to understand

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Sep 2006
Posts: 27
Reputation: donaldunca is an unknown quantity at this point 
Solved Threads: 0
donaldunca's Avatar
donaldunca donaldunca is offline Offline
Light Poster

difficult to understand

 
0
  #1
May 11th, 2007
I have just learnt C so I always meet some problem
Could you tell me the meaning of this code?
  1. void InsertListOrder(Nodeptr &Head,Nodeptr G)
  2. {
  3. Nodeptr P, Q;
  4. P = Head;
  5. while (P != NULL)
  6. {
  7. if (strcmp(P->key.tu,G->key.tu)>0) break;
  8. Q = P;
  9. P = Q->next;
  10. }
  11. if (P == Head)
  12. {
  13. G->next = Head;
  14. Head = G;
  15. }
  16. else
  17. {
  18. G->next = Q->next;
  19. Q->next = G;
  20. }
  21. }
I don't understand "nodeptr &Head"
thank you
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,500
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1479
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: difficult to understand

 
0
  #2
May 11th, 2007
That is a reference to a nodeptr object in another function. The object is passed by reference so that InsertListOrder() can change its value. Any changes to Head in funciton InsertListOrder will be made to the object in the function that calls InsertListOrder().
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC