C++ Linked List

Discussion in 'Computer Science & Culture' started by gram1234, Mar 9, 2003.

Thread Status:
Not open for further replies.
  1. gram1234 Registered Member

    Messages:
    18
    Having trouble with my linked list function to remove duplicates,becoming really frustrated.Any suggestions greatly appreciated.Thanks.
     
  2. Google AdSense Guest Advertisement



    to hide all adverts.
  3. DCLXVI Bloody Bastard Registered Senior Member

    Messages:
    363
    Here's a function to remove a linked list...
    Code:
    void delList( bnode* h )
    {
       if( h == NULL ) return;
    
       bnode *p = h->next;
       while( p != NULL ) {
          delete h;
          h = p;
          p = p->next;
       }
    }
    
    bnode being for example...
    
    struct bnode {
       int val;
       bnode* prev;
       bnode* next;
    
       bnode( int x, bnode* p, bnode* n )
       {   val = x; prev = p; next = n;   }
    };
    
    Is this what you were talking about?
     
  4. Google AdSense Guest Advertisement



    to hide all adverts.
  5. gram1234 Registered Member

    Messages:
    18
    linked list

    that's it ,thanks alot.
     
  6. Google AdSense Guest Advertisement



    to hide all adverts.
Thread Status:
Not open for further replies.

Share This Page