GameState *currentState = NULL;
Is a variable that is declared twice - in two source files; main.cpp and gamestates.cpp.
When it is declared twice, the compiler returns the following:
1>main.obj : error LNK2005: "class GameState * currentState" (?currentState@@3PAVGameState@@A) already defined in gamestates.obj
Then, if declared only in main.cpp, the compiler returns:
1>c:\users\9101757\documents\visual studio 2010\projects\motion\motion\gamestates.cpp(61): error C2065: 'currentState' : undeclared identifier
I get a series of errors of the same style (only related to gamestates.cpp - the rest compiles successfully).
Then, if only declared in gamestates.cpp - not main.cpp, I get:
1>c:\users\9101757\documents\visual studio 2010\projects\motion\motion\main.cpp(485): error C2065: 'currentState' : undeclared identifier
and another series of errors (only from main.cpp).
I was hoping that someone could tell me how to solve this error without porting code between files. I can successfully carry each function/variable from gamestates.cpp over to main.cpp and compile successfully (as GameState *currentState = NULL; is only declared once).
Thanks in advance.