1#include <iostream>
2
3using namespace std;
4
5struct node
6{
7 int data;
8 node *next;
9};
10
11class linked_list
12{
13private:
14 node *head,*tail;
15public:
16 linked_list()
17 {
18 head = NULL;
19 tail = NULL;
20 }
21
22 void add_node(int n)
23 {
24 node *tmp = new node;
25 tmp->data = n;
26 tmp->next = NULL;
27
28 if(head == NULL)
29 {
30 head = tmp;
31 tail = tmp;
32 }
33 else
34 {
35 tail->next = tmp;
36 tail = tail->next;
37 }
38 }
39};
40
41int main()
42{
43 linked_list a;
44 a.add_node(1);
45 a.add_node(2);
46 return 0;
47}
1#include <iostream>
2
3using namespace std;
4
5struct node
6{
7 int data;
8 node *next;
9};
10