I have my header file in which i have the "selection" as you can see it's public static member .
#ifndef SHAREDDATA_H_
#define SHAREDDATA_H_
#include "cocos2d.h"
#include "GameTrinkets.h"
using namespace std;
class SharedData{
private:
//...
//Instance of the singleton
static SharedData* m_mySingleton;
public:
//Get instance of singleton
static SharedData* sharedGameManager();
static int selection;
};
#endif /* SHAREDDATA_H_ */
Where i try to get access is:
- I tried setting the selection trough just the namespace as it seemed the correct way to do it
- I tried by going trough the singleton instance but got unlucky
So the code where i try it
#include "GameScene.h"
#include "GameTrinkets.h"
#include "SharedData.h"
#include <time.h>
void GameScene::mainSpriteSelection(int selection){
//1
SharedData::selection=3;
//2
SharedData::sharedGameManager()->selection=selection;
}
The error i get is :
[armeabi] SharedLibrary : libcocos2dcpp.so jni/../../Classes/GameScene.cpp:41: error: undefined reference to 'SharedData::selection'