Thread: 1st Class LIST ADT

  1. #1

    1st Class LIST ADT

    Hi all,
    I am tyring to create a first class ADT List. Unfortunately, i am getting a number of syntax errors that i don't understand. The first one concerns "list L = *this" . "cannot convert from
    'class LIST' to 'struct LIST::list_node *'" If someone has a better way to do the deletelist() function feel free to sugest it. Any help is appreciated! Thanks!

    class LIST
    typedef int boolean;
    typedef char data;
    struct list_node
    data info;
    list_node *next;
    typedef list_node list_head;
    typedef list_head *list;

    void deletelist()
    list L = *this;
    list_node* T;

    while(L != NULL)
    T = L;
    L = L->next;
    delete T;
    LIST(const LIST &rhs)
    *this = rhs;
    LIST& operator=(const LIST& rhs)
    list_node* L;
    data the_data = rhs->next->info;

    if(this == &rhs)
    return *this;

    L = copy(rhs);
    return *this;


    void printlist (list);
    void printlist_NR (list);
    list nullist(void);
    boolean null(list);
    data car(list);
    list cdr(list);
    list cons(data, list);
    data read_element(void);
    list readlist_element(void);
    list readlist_element_NR(void);
    list readlist(void);
    list readlist_NR(void);
    int longer(list, list);
    list delete3(data, list);
    list del_all(data, list);
    list copy(list);
    list rotate(list);
    list list_reverse_NR(list);
    list list_reverse(list);
    int length(list);
    int length_NR(list);
    list append(list, list);
    list append_NR(list, list);

    }; // end of class

  2. #2
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    list is a typedef of a list_node but *this is a LIST. I don't think it's necessary to try and assign *this to list L, you shouldn't need a copy. Use a copy of the head of your list to walk through it deleting. Something like

    delete list_copy;

    where list_iterator is initially a copy of your head pointer.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with FIFO QUEUE
    By jackfraust in forum C++ Programming
    Replies: 23
    Last Post: 04-03-2009, 08:17 AM
  2. Following CTools
    By EstateMatt in forum C Programming
    Replies: 5
    Last Post: 06-26-2008, 10:10 AM
  3. deriving classes
    By l2u in forum C++ Programming
    Replies: 12
    Last Post: 01-15-2007, 05:01 PM
  4. instantiated from here: errors...
    By advocation in forum C++ Programming
    Replies: 5
    Last Post: 03-27-2005, 09:01 AM
  5. link list
    By Unregistered in forum C++ Programming
    Replies: 4
    Last Post: 12-13-2001, 05:41 AM