How to assign and read values of public members of singleton class I have a class accessed as singleton with public members:
class MySingleton{
public:
    static MySingleton& Instance();
    int x;
...
}


the class is accessed as following:
MySingleton& MySingleton::Instance(){
static MySingleton instance;
return instance;
}

When i try to get the value of x i don't get the value i assigned before. i checked it with prints. 
What is the proper way to change/get the value of x? should i use setters/getters? or can i do it directly in assignment?
Thank you all
Edit:
I have a single write to x as follows:
MySingleton::Instance().x = 2;

I get inconsistent values when i try to get x by accessing from different classes (single thread):
int z = MySingleton::Instance().x;