Linked List Program – Algorithms & Data Structures in C++

#include <iostream>
#include <conio.h>

using namespace std;

struct node
{
int data;
node *next;
};

class list
{
private:
node *head, *tail;
public:
list()
{
head=NULL;
tail=NULL;
}
void createnode(int value)
{
node *temp=new node;
temp->data=value;
temp->next=NULL;
if(head==NULL)
{
head=temp;
tail=temp;
temp=NULL;
}
else
{
tail->next=temp;
tail=temp;
}
}

void display()
{
node *temp=new node;
temp=head;
while(temp!=NULL)
{
cout<<temp->data<<“\t”;
temp=temp->next;
}
}

};

int main(){

struct node object;
list obj;
obj.createnode(7);
obj.createnode(8);
obj.createnode(9);
obj.createnode(10);
obj.display();

return 0;
}