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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.