Here is the code, it's pretty straightforward.

```
class Foo
{
public:
    void print()
    {
        std::cout<<"Foo::print\n";
    }
}; 

Game::Game()
{
    {
        Foo foo;
        player.onclick = bind(&Foo::print,foo);

    }
    player.onclick();
}

```

After the inner scope is done the foo object goes out of scope, but the print method is still called, I guess this happens because player holds a reference to the foo object? Is there a way to stop this from happening? I don't want objects to stay alive and receive events when they are supposed to be destroyed.

Thanks.