code not working
#include
using namespace std;
class node
//creating anode clas which consistof a constructor which furthrt consist of data
// and next pointer
{
public:
int data;
node* next;
node(int d)
{
data=d;
next = NULL;
}
};
void insertathead(node*&head,int data)
{
node* n=new node(data);
n->next=head;
head =n;
}
void printlist(node* head)
{
node* temp=head;
while(temp!=NULL);
{
cout<data<<"->";
temp=temp->next;
}
}
int main()
{
node*head= NULL;
insertathead(head,1);
insertathead(head,2);
insertathead(head,3);
insertathead(head,4);
printlist(head);
}