fork(4) download
  1. #include <iostream>
  2. #include <cstdlib>
  3. using namespace std;
  4. #ifndef Null
  5. #define Null 0
  6. #endif
  7.  
  8.  
  9. class Node
  10. {
  11. public:
  12. int data;
  13. Node *link;
  14. };
  15.  
  16. class LList
  17. {
  18. public:
  19. LList ();
  20. ~LList();
  21. void create();
  22. void display();
  23. Node* getNode();
  24. void append(Node* NewNode);
  25. void insert(Node *NewNode, int pos);
  26. void rtraverse();
  27. void deleteNode(int deletePos);
  28. private:
  29. Node *Head, *Tail;
  30. void recursiveTraverse (Node *tmp)
  31. {
  32. if (tmp == Null)
  33. {
  34. return;
  35. }
  36. cout << tmp->data << "\t";
  37. recursiveTraverse (tmp->link);
  38. }
  39. };
  40.  
  41. LList :: ~LList ()
  42. {
  43. Node *Temp;
  44. while (Head != Null)
  45. {
  46. Temp = Head;
  47. Head = Head->link;
  48. delete Temp;
  49. }
  50. }
  51.  
  52. void LList :: create ()
  53. {
  54. char ans;
  55. Node *NewNode;
  56. while (1)
  57. {
  58. cout << "Any more nodes to be added (Y/N):";
  59. cin >> ans;
  60. if (ans == 'n' || ans == 'N')
  61. {
  62. break;
  63. }
  64. NewNode = getNode ();
  65. append(NewNode);
  66. }
  67. }
  68.  
  69. void LList :: append(Node* NewNode)
  70. {
  71. if (Head == Null)
  72. {
  73. Head = NewNode;
  74. Tail = NewNode;
  75. }
  76. else
  77. {
  78. Tail->link = NewNode;
  79. Tail = NewNode;
  80. }
  81. }
  82.  
  83. Node* LList :: getNode()
  84. {
  85. Node *Newnode;
  86. Newnode = new Node;
  87. cin >> Newnode->data;
  88. Newnode->link = Null;
  89. return (Newnode);
  90. }
  91.  
  92. void LList :: display()
  93. {
  94. Node *temp = Head;
  95. if (temp == Null)
  96. {
  97. cout << "Empty List";
  98. }
  99. else
  100. {
  101. while(temp != Null)
  102. {
  103. cout << temp->data << "\t";
  104. temp = temp->link;
  105. }
  106. }
  107. cout << endl;
  108. }
  109.  
  110. int main()
  111. {
  112. LList L1;
  113. L1.create();
  114. L1.display();
  115.  
  116. return 0;
  117. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
/home/2iLihC/ccDAPJvF.o: In function `main':
prog.cpp:(.text.startup+0x13): undefined reference to `LList::LList()'
collect2: error: ld returned 1 exit status
stdout
Standard output is empty