Pointers to lists
Posted: 09 Dec 2005, 18:55
Say i declare two (or more) lists:
list<int> *things;
list<int> *stuff;
then fill them up with things and stuff(respectively)...
Now say i have a function that performs a loop on these lists, and to not need to write the function once for each list, i thought about creating a pointer to a list:
list<int> *pointertolist = things;
which gave me an AI exception (compiled no probs!)
How can i perform a loop thru a set number of lists?
also: are there any advantages to lists over vectors/deques?
finally: if i delete an element in the middle of the list/vector/deque, what happens?
thanks!
list<int> *things;
list<int> *stuff;
then fill them up with things and stuff(respectively)...
Now say i have a function that performs a loop on these lists, and to not need to write the function once for each list, i thought about creating a pointer to a list:
list<int> *pointertolist = things;
which gave me an AI exception (compiled no probs!)
How can i perform a loop thru a set number of lists?
also: are there any advantages to lists over vectors/deques?
finally: if i delete an element in the middle of the list/vector/deque, what happens?
thanks!