Reputation: 346
i'm starting to explore a brand new world for me that is the world of the games. I've started using the cocos2d framework to get the interface done. The brain of the game is a c++ class that is called when in the interface happens something. As this brain should keep track of everything and keep track on what happened in the game, i think that the correct design pattern is the singleton one. Now my question is :" does anyone have experience in creating singletons in c++ and add those to an iphone app " Obviously i've googled for a day and read a lot of docs but the informations i've got are not very clear Links are welcome! thanks
Upvotes: 0
Views: 72
Reputation: 15075
Isn't the following good enough for your purposes?
Singleton& instance()
{
static Singleton singleton;
return singleton;
}
Upvotes: 1