Hey just a quick question with list <Object*> object;

when i put an object in the container i use

object.push_front(new thing(param1,param2,param3,param4,param5));

because i have used new how do i go about deleting this certain object in the list i figured somthing like this

while(p != object.end()) 
{	
	if((*p)->exists(param))
	{					
	   delete *p; // delete allocated in the list
	}
        else
        {
	   p++;
	}
}

p is also declared as list<Object*>::iterator p; and has been assigned to begin()
basicly i want to delete from the list when the user has enterd somthing for param so say param is an int and user enters param = 1 then delete list that has param == 1
thats what exist does btw it just returns true where the object has param == 1
this is in c++ btw.

Edited 5 Years Ago by ghostile: iterator

dont worry i figured it out

while(!object.empty())
	{
		 delete object.front();
		 object.pop_front();
	}

etc that was finaly clean up but i use same code just pushed the object i found to the front then delete + poped it off thxs

This question has already been answered. Start a new discussion instead.