fork download
  1. #include "list.h"
  2. #include <iostream>
  3. #include <cstdlib>
  4. using namespace std;
  5.  
  6. /*
  7. Node* prefix(int value, Node* head)
  8. {
  9.   head = new Node(value,head);
  10.   return head;
  11. }
  12. */
  13.  
  14. int main()
  15. {
  16. // singlton list model
  17. // create the first node with a pointer variable referencing it
  18.  
  19. // singleton list model
  20. /*
  21.   Node* head = new Node;
  22.   head->setValue(0);
  23.   head->setNext(NULL);
  24.   */
  25.  
  26. Node headNode(0,NULL);
  27. Node* head = &headNode;
  28.  
  29. // null list model
  30. /*
  31.   Node* head = NULL;
  32.   head = prefix(0,head);
  33.   */
  34.  
  35. for(int i = 1; i < 1000; ++i)
  36. head = head->prefix(i,head);
  37.  
  38. // make copy of head to traverse our list
  39. Node* trav = head;
  40. while(trav != NULL)
  41. {
  42. cout << trav->value << endl;
  43. trav = trav->next;
  44. }
  45.  
  46. free(head); // return memory allocated to the list structure to the freestore
  47.  
  48. return 0;
  49. }
  50.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:18: fatal error: list.h: No such file or directory
compilation terminated.
stdout
Standard output is empty