Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. class SmartList {
  2. private:
  3. struct Node {
  4. AppliancePtr app;
  5. Node* next;
  6. };
  7.  
  8. Node* head;
  9. Node* cur;
  10.  
  11. public:
  12. SmartList(){
  13. head = NULL;
  14. cur = NULL;
  15. }
  16.  
  17. void addNode(AppliancePtr newApp) {
  18. Node* newNode = new Node();
  19. newNode->app = newApp;
  20. newNode->next = NULL;
  21.  
  22. if (head != NULL) {
  23. cur = head;
  24.  
  25. while (cur->next != NULL) {
  26. cur = cur->next;
  27. }
  28.  
  29. cur->next = newNode;
  30. }
  31. else {
  32. head = newNode;
  33. }
  34. }
  35. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement