On Jan 28, 5:51 pm, "Daniel T." <danie...@earthlink.net> wrote:
> "simran_hello_...@yahoo.com" <simran_hello_...@yahoo.com> wrote:
> > content=// Program to implement Linked List.
>
> Odd choice of algorithms.
>
> > void list::remove(int value)
> > {
> > node* thisptr=searchnode(value);
>
> > if (!thisptr) return; //????????????
>
> If searchnode() didn't find a node which has its data equal value, then
> return and do nothing.
If searchnode() didn't find a node it returns a 0-pointer and if an
expression in an if-statement evaluates to 0 it's treated like false,
so 'if (false)' is the same as 'if (0)'. It's kind of bad style to
write code like that, it's better to actually write what you mean so
'if (thisptr == 0)' would be better.
> > while (thisptr->ptr) //???????????
Same thing here.
--
Erik Wikström
|