For my C++/SDL 2d game I am doing the same sort of thing where I have a manager that keeps a vector list of gracphics objects and can render them according to an ID or a string name. For you to compare string values you have to do a
.compare(value)==0
I store an name, ID and an image type in my graphics object. The ID or name are referencing the owner of the image. The type refers to a standard image type. This can easily be associated with an animation list so that current images from a running animation can be pulled from the library.
Here is one of my routines for rendering images
void gFXManager::renderImage(SDL_Surface *screen, string name, int type, int x, int y){
for(int i=0; i < this->gFXList.size(); i++){
if(this->gFXList->getName().compare(name)==0 && this->gFXList->getType()==type){
//Render the image to the surface
this->gFXList->drawImage(screen, x, y);
break;
}
}
}
This code should almost certainly use a map in place of a vector, especially if you have a lot of items. There are two reasons for this, first the vector will simplify your code and as a result make it less error prone and easier to maintain. You would eliminate the loop completely. Second, as complexity grows the search will certainly be faster on a map than a raw iteration over elements.
Small quibbles, you should use an iterator. Also, generally prefer pre-increment operators ( ++i ) over post-increment ( i++ ) unless you have a reason to do otherwise. In a for loop, they will be functionally identical, but the use of a post increment can result in a variable being creating each iteration, depending on your compiler. I think most are smart enough to deal with this, but it's a low hanging fruit thing to get in the habit of changing.