--- ~Rick <[EMAIL PROTECTED]> wrote:

> At Monday 6/2/2008 02:58 PM, you wrote:
> >--- In [email protected], Mickey Mathieson
> <[EMAIL PROTECTED]> wrote:
> > >
> > > You might consider altering your function to
> return
> > > the value of the NEW first node.
> > >
> > >  ENTRY* delete_first_node(struct ENTRY *llist)
> > >  {
> > >       struct ENTRY    *temp;
> > >       struct ENTRY    *first;
> > >
> > >       temp = llist;
> > >       first = llist -> next;
> > >       delete temp;
> > >       return(first);
> > > }
> >
> >Just nitpicking, but do you need temp?
> >
> >     first = llist->next;
> >     delete llist;
> >     return first;
> 
> I'd rather not have to return the new value. Thanks
> to Nico, here's 
> my working code:
> 
> void delete_first_node(struct ENTRY **llist)
> {
>      struct ENTRY    *tlist  = *llist;
>      struct ENTRY    *new1st;
> 
>      if (!tlist)
>      {
>          return;
>      }
> 
>      new1st = tlist->next;
>      if (tlist->data)
>      {
>          delete tlist->data;
>      }
>      delete tlist;
>      *llist = new1st;
>      tlist = *llist;
> 
>      return;
> }
> 
> BTW: I tried:
> 
>      struct ENTRY    *new1st = *llist->next;
> 
> and got compile-time errors.
> 
> list.cpp        In function `void
> delete_first_node(ENTRY**)':
> 322 list.cpp    `next' has not been declared
> 322 list.cpp    request for member of non-aggregate
> type before ';' token
> 
> ~Rick 
> 
> 
JUst trying to be helpfull. I don't understand your
logic however. Returning a value makes it VERY CLEAR
what the function does - a pointer to a pointer is NOT
very clear. And another programer might not understand
why pointer to pointer is requirred.

To me the anser is very simple - return the value!


Mickey M.
Construction Partner Inc.
http://www.constructionpartner.com


      

Reply via email to