i think that code was posted by you. I am not allocating any new memory
i think that code was posted by you. I am not allocating any new memory
My GNU/Linux Blog:
http://funwithlinux.blogspot.com
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.
Please let me know what do you think
Last edited by Sandip; 8th October 2008 at 13:47. Reason: updated contents
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
Bookmarks