Why Implementing Singleton like This?

Why Implementing Singleton like This?
0.0 0


In proj.android/jni/hellocpp/main.cpp I see this:
AppDelegate *pAppDelegate = new AppDelegate();

Though it works (sharedApplication was initialized in the constructor of AppDelegate), it looks confusing. Why implementing the singleton like this? Why not implementing a sharedAppDelegate() method in AppDelegate instead?



AppDelegate inherits CCApplication to override just few methods where your application specific work is done. The engine does not need sharedAppDelegate() (but you can implement it if you need it), but it does need sharedApplication to call CCApplication’s (and overriden in AppDelegate) methods.

Anyway as far as I know this is the way AppDelegate is originally implemented in Cocoa. Authors of Cocos2d-x just ported it to C++.