Hello! I'm very new to STL and have run across a fairly rudimentary question. Let's say I've got a vector as follows:
Code:
vector<Tangible*> tangibles;
Let's say I've got the following function definition:
Code:
Tangible* theReturn = NULL;
vector<Tangible*>::iterator iterator;
for (iterator = tangibles.begin(); iterator != tangibles.end();
iterator++)
{
if (iterator->get_tangibleType() == tangibleType)
{
theReturn = iterator;
tangibles.erase(iterator);
break;
}
}
return theReturn;
Apparently that doesn't work too well. Basically I just want to go through tangibles, find the first element whose "tangibleType" is equals to the value specified, set theReturn to that element (which is a pointer), pull the element out of the vector, and return theReturn. How should this block of code be written? Thanks!