943,963 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 744
  • C RSS
May 11th, 2007
0

difficult to understand

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
donaldunca is offline Offline
27 posts
since Sep 2006
May 11th, 2007
0

Re: difficult to understand

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().
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,953 posts
since Aug 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: Lo and behold. God just went open source.
Next Thread in C Forum Timeline: Behaviour of Binary Search Program





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC