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
{
private:
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;
}
}
public:
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;
deletelist();
L = copy(rhs);
return *this;
}
~LIST()
{deletelist();}
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