Still fresh, damnit!
- Oct 6, 2008
- Somewhere off the coast of the EU
Ah, it must be a naming convention or something.There's a typedef at the bottom of the game.hpp and inputHandler.hpp files which define those. I'll be honest, I don't understand them, and why they're needed. I usually don't like using code that I don't understand, but occasionally I do it if it's a small thing like this.
They are basically a renaming of the Game and InputHandler objects so that when I call them, instead of Game I'll call TheGame, but it's really just calling the functions in the Game class. I have no idea why that's necessary, but that's what I was taught by my learning materials to do for singletons. But if you want to learn more, google typedef.
I think the thing that makes these objects singletons is the fact they maintain a static _instance and their Instance method checks for that when you try to instantiate one, so you just get the same old one if there is one. If it's just a naming convention I don't know why you don't name the class itself TheGame and so on though.
IIRC I only learned singletons in a C++ context, and the naming conventions there were a lot more lax back when I learned it (1996-ish).