How can I remove an element in a list when I have only an iterator that points to the object I want to remove. Is there a build in command? remove() takes an object reference as its argument. Is it possible to convert the iterator into a pointer type so it can be deferenced and passed to remove?
//player.cpp
void Player::CheckCollectableCollisions(std::list<Collectable>& c)
{
std::list<Collectable>::iterator i = c.begin();
while(i != c.end())
{
if (Collider::CheckCollision(pNodes_.front().getLocation(), i->getLocation()))
{
AddNode(i->GetMealSize());
creator_.getCollectableManager().Remove(i);
}
i++;
}
}
//CollectableManager.cpp - this is the function I am trying to work out how to implement
//mainly what parameters should it have?
void CollectableManager::Remove(std::list<Collectable>::iterator col)
{
std::list<Collectable>::iterator i = collectables_.begin();
while (i != collectables_.end())
{
if (i == )
}
}