Can a C++ map contain a pointer to my arbitrary class?
===

I am writing a small game engine as a summer project, and am struggling a little with the STL map.

I have declared a class `RenderList` to hold objects. The RenderList will be passed to a `Renderer` class to do the work.

The `RenderList` has a `map<std::string,Entity*> objects;`

That all works, till I try to obtain an `Entity*` from the map and I get:

Assertion failed, in vc/include/xtree
Expression: map/set iterator not dereferencable.

This is the code to retrieve the pointer.

    Entity* RenderList::getByName(std::string str){
        return objects.find(str)->second;
    }

I need it to hold a pointer and not the actual object, as there are different sub-classes of `Entity` which I'll need.

I am fairly new to the STL, should I not store pointers in a map?

Surely I should be allowed to do this, or is it a better idea to store objects instead?

And finally, am I simply doing it wrong!?

Hope this question is not a duplicate, I did do a quick search beforehand. Also if this would be better in the GameDev Stack I'll post it there.

Thanks all.

