This code is for implementation of linked list.
node *single_llist::create_node(int value)
{
struct node *temp, *s;
temp = new(struct node);
if (temp == NULL)
{
cout<<"Memory not allocated "<<endl;
return 0;
}
else
{
temp->info = value;
temp->next = NULL;
return temp;
}
}
Here, why are we checking if temp == NULL. I can't think of any case where this can happen
Also to exit from if, why are we returning 0 since the return type is node?
NULL==0
, which is often true, but not necessarily so, and (as we both seem to think) is a bad assumption to make.