How to access variables of uninitialized class?

Posted by oringe on Game Development See other posts from Game Development or by oringe
Published on 2012-10-29T01:33:43Z Indexed on 2012/10/29 5:22 UTC
Read the original article Hit count: 173

Filed under:

So I've gone with a somewhat singleton approach to my game class:

#include "myGame.h"

int main () {
    myGame game;
    return game.Execute();
}

But now I need to define a class that accesses variables in the instance of myGame.

class MotionState {
    public:
    virtual void setWorldTransform (...) {
        VariableFromMyGameClass++;            //<-- !?
        ...}
};

I'm trying to integrate this class into my project from an example that just uses globals. How can I access variables of myGame class in the definition of new classes? Should I give up on my singleton approach?

© Game Development or respective owner

Related posts about c++