Re: Problems accessing static member variable from static member function
Hi,
You can try a different solution.
Let's see it is easy and safe also.
class GetComboInstance
{
public:
static GetComboInstance* createInstance();
updateCombo();
private:
QComboBox *m_pComboBox;
static GetComboInstance *m_pInstance;
};
In Cpp file:
static GetComboInstance *GetComboInstance::m_pInstance = NULL;
static GetComboInstance* GetComboInstance::createInstance()
{
if(m_pInstance == NULL)
{
m_pInstance = new GetComboInstance();
}
return m_pInstance;
}
now you can call updateCombo method on your instance of GetComboInstance class from any class. It is better and safe way.
Re: Problems accessing static member variable from static member function
Please let me know what do you think
Re: Problems accessing static member variable from static member function
I think that when you describe the singleton pattern, you should do it right, e.g. make constructors protected or private. ;-)
http://www.inquiry.com/techtips/cpp_.../10min0200.asp