Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Well I think that yyy is a private member variable inside of xxx so maybe that is why the did that?

Like:

#define GAMELAYERINSTANCE _dir->Instance()->getGameScene()->Instance()->getGameLayerObject()->Instance()



You mean getGameSceneClass() and getGameLayerClass(), yes? As in Dependency Injection?

object->getInstance() makes no sense, you already have the object!


I may be reading this weird. object->getInstance makes no sense? You mean if object is a private member variable?

So class _dir contains object as a member variable.

_dir->Instance(), already has access to object without doing _dir_Instance()->object->Instance() as an example...?


> object->getInstance makes no sense?

If getInstance returns an instance of object class, and object is an instance itself, then it doesn't make sense or it is not a singleton.

You can think it like this: if object class has one unique instance, then object == object->getInstance(), so in your case either object != object->getInstance and they are from the same class (hence it is not a singleton) or they are from different classes (once again then, it is not a singleton).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: