I do not know if this is the best way to handle these `SDL_Event`s, but I am attempting to create a very abstract and generic code that will update my game object. I have a `Scene` which in my case is just a map from a string to a game object that has special functions to `Add(string key, gameobject value)`, `Remove(string key)`, `Render()`, and `Update(SDL_Event& event)`. I think this last method is the problem.

Scene.cpp
---------

```
void Scene::Update(SDL_Event& ev)
{
    for (std::map<std::string, GameObject&>::iterator it = x_ObjectDictionary.begin(); it != x_ObjectDictionary.end(); ++it)
    {
        it->second.Update(ev); //where the game crashes
    }
}

void Scene::Render()
{
    for (std::map<std::string, GameObject&>::iterator it = x_ObjectDictionary.begin(); it != x_ObjectDictionary.end(); ++it)
    {
        it->second.Render();
    }
}

void Scene::Add(const std::string& key, GameObject& value)
{
    x_ObjectDictionary.insert(std::pair<std::string, GameObject&>(key, value));
}

GameObject& Scene::Get(const std::string& key)
{
    std::map<std::string, GameObject&>::const_iterator iterator = x_ObjectDictionary.find(key);
    if (iterator == x_ObjectDictionary.end()) return GameObject();
    return iterator->second;
}

GameObject& Scene::Remove(const std::string& key)
{
    GameObject removed;
    std::map<std::string, GameObject&>::const_iterator iterator = x_ObjectDictionary.find(key);
    if (iterator == x_ObjectDictionary.end()) return GameObject();
    removed = iterator->second;
    x_ObjectDictionary.erase(iterator);
    return removed;
}

```

This iterates my map and updates all of the `GameObject`s. My game object update method is defined like this in the header file:

GameObject.h
------------

```
class GameObject
{
public:
    GameObject() {}
    virtual ~GameObject() {}

    virtual void Update(SDL_Event& ev){}

    virtual void Render(){}

    virtual void Destroy(){}

};

```

Now, I created a scene. This `Scene` is called `Splash` and extends `Scene` properly. I created it like so

```
void Splash::CreateScene()
{
    Add("something", GameObject());
}

```

Every time I execute/debug my project now, my program "breaks" on the `it->second.Update(ev);` line and inside the console after I stop "debugging" the message says something along the lines of `Exception thrown at 0x00007FF7CB457024 in XXXXXX.exe: 0xC0000005: Access violation reading location 0x00001CFA67BC13F9.`

Am I going about this completely incorrectly? Or did I just make a stupid mistake?