Hello,
I guess this is not cocos strictly related so I posted in c++ forum.
I am having trouble understanding why this works:
// this is in a gameGlobals.h
struct GameGlobals
{
public:
static ParallaxInfiniteNode* level1ParallaxNode;
//...more code
}
//this is in the source file
#include "gameglobals.h"
USING_NS_CC;
ParallaxInfiniteNode* GameGlobals::level1ParallaxNode = nullptr; // all good
//...more code
but if I simply add this last line in the header file as so:
// this is in a gameGlobals.h
struct GameGlobals
{
public:
static ParallaxInfiniteNode* level1ParallaxNode;
//...more code
}
ParallaxInfiniteNode* GameGlobals::level1ParallaxNode = nullptr; // ERROR
I am not sure why assigning nullptr in the source file make everything work ok as expected, but taking that very same line from the source file to the header file fives a linking error (LNK1169: one or more multiply defined symbols found.) It is not possible to initialize a static null pointer in the header?