im new in c++
my problem: this is my singleton:
class Singleton
{
static Singleton *singletonInstance;
Singleton() {}
public:
int numero = 0;
static Singleton* getSingletonInstance()
{
//std::lock_guard<std::mutex> lock(m_);
if(singletonInstance == nullptr)
{
singletonInstance = new Singleton();
}
return singletonInstance;
}
};
this is another file .cpp where i set or get the "numero" variable:
Singleton.getSingletonInstance()->numero = 10;
I get this error:
error: expected unqualified-id before '.' token
Singleton.getSingletonInstance()->numero = 10;
How do to set "numero" variable and get/set the numero from sigleton in/from other class .cpp ? My target is use this singleton. I'm new in c++. Where I wrong ? Thanks