Hi,Is someone could help me how is it possible to implement Generalized Linked Lists?
I've implemented it somehow but I'm not sure it works or not. Now I'm going to print the nodes I've implemented.When I want to declare the print function in class Glist with first1 argument,I get this eror: syntax error : identifier 'first1'.I don't know why it couldn't recognize first1 though I've already declared it in class Glist.
class Gnode {
public:
int tag;
int flag;
char* data;
Gnode* link;
Gnode* dlink;
};
class Glist {
public:
Gnode* first1;
Gnode* first2;
public:
Glist () {
first1=new Gnode;
first2=new Gnode;
first1->link=NULL;
first1->dlink=NULL;
first1->tag=0;
first1->flag=0;
first1->data=NULL;
first2->data=NULL;
first2->tag=0;
first2->link=NULL;
first2->dlink=NULL;
}
void Add ();
void print (first1);
}
};
void Glist::print(Gnode* p){
if (p->tag==0)
cout<<p->data;
else {
print(p->dlink);
p=p->link;
}
}