Guest User

Untitled

a guest
Sep 22nd, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. My struct contains the pointer:
  2.  
  3. // define a structure to hold bid information
  4. struct Bid {
  5. string bidId; // unique identifier
  6. string title;
  7. string fund;
  8. double amount;
  9. Bid *next;
  10. Bid() {
  11. amount = 0.0;
  12. next = NULL;
  13. }
  14. };
  15.  
  16. void LinkedList::Append(Bid bid) {
  17. // FIXME (3): Implement append logic
  18.  
  19. //reference bid being passed??? Bid struct has pointers, do we need another pointer?
  20. Bid *currNode = &bid;
  21.  
  22. //set node's next pointer to NULL (end)
  23. currNode->next = NULL;
  24.  
  25. //if list is empty
  26. if (head == NULL) {
  27. head = currNode;
  28. tail = currNode;
  29. }
  30. else {
  31. tail->next = currNode;
  32. tail = currNode;
  33. }
  34. }
Add Comment
Please, Sign In to add comment