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!
Pointers to lists
Moderators: hoijui, Moderators
hmm shouldnt there be a
thing = new list<int>;
somewhere?
if all else fails,
thing = new list<int>;
somewhere?
if all else fails,
Code: Select all
list<int> a;
list<int>* b = &a;
Code: Select all
list<int>* a;
list<int>* b;
a = 0;
a = new list<int>;
b = a;
if(b != 0){
if(b->empty() != true){
// code
}
}
delete a;
b= 0;
& olny returns the address of the variable.yes there is a
thing = new list<int>;
ill try the & , it might work...
Code: Select all
list<int*> a;
list<int*> *b = &a;
Code: Select all
list<int*> *a = new list<int*>;
list<int*> *b = a;
to search for and delete a list member:
Code: Select all
list<MyClass*> *mMyClassList = new list<MyClass*>;
...
MyClass *fMyClass = 0;
for(list<MyClass*>::iterator i = mMyClassList->begin(); i != mMyClassList->end(); i++)
{
if((*i)->mID == pID)
{
fMyClass = (*i);
}
}
mMyClassList->remove(fMyClass);