How to access variables of uninitialized class?
- by oringe
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?