Does anyone know how to pass a linked list (of objects) as a reference ??
I can get my program working if I have the list global but I assume this is bad coding ??
Thanx
Lisa
x
Does anyone know how to pass a linked list (of objects) as a reference ??
I can get my program working if I have the list global but I assume this is bad coding ??
Thanx
Lisa
x
just pass the address of the head node. remember that from that node to can walk to anywhere within the list by following the next pointers. You could also pass as a reference to the head object of the list etc.
Free the weed!! Class B to class C is not good enough!!
And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi
OK, I still can't get it working, here is an example of what I am doing:
I have a linked list of videos (called li):
list <vid> li;
I have declared an iterator (not sure if it helps)
list<vid>::iterator it;
I want to print out the list of films in a seperate function to main, I therefore need to pass a reference to the list into the function !!??
I need some sample code to help me please, this is really bugging me now !!!
Thanks
L
OK, solved it myself by passing the list as a reference , seemed to work:
in main :
viewList(li);
Function prototype :
void viewList(list<vid> &li);
can then use li as normal.