You can't, the names are just for you. You could emulate this however by doing something like std::map<std::string, int> or something where each string maps to an int variable.
What I want to actually do is read data off an xml file. The attributes for the element I want to get from are put into strings during a For Each loop:
I'm using SDL, sorry for not specifying, and for lying about the int thing. It was for simplicity. It was one of the solutions I thought of. Anyway, I want to create an SDL_Surface for each time TinyXml finds an "image" element in the xml file. The attribute "id" is pretty much just a name for the image, which I'd like to reference to later, in other files. Is there any other way I could do this where the SDL_Surface would be different and recognizable for each separate "image" element?
Well, you could have each image have a "name" element and shove them all into one big array, then you could search for them. I think a map would still be a better choice though, if you don't need to construct them.
std::map<std::string, SDL_Surface>
Or if you are using pointers like it seems you are, a boost::ptr_map might be a better choice:
boost::ptr_map<std::string, SDL_Surface> //this works differently than std::map<std::string, SFL_Surface>, check documentation
Doesn't boost::ptr_map work with newed pointers? If so, then it won't work, because SDL_Surface structs aren't newed.
An std::map<std::string,SDL_Surface *> would probably be best.