Вот в этом случае всё отлично :
typedef void(*pCallback)(void);
class CClass
{
private:
explicit CClass(void);
public:
~CClass()
{
m_pInstance = NULL;
}
static CClass* GetInstance()
{
if (!m_pInstance)
{
m_pInstance = new CClass();
}
return m_pInstance;
}
private:
void _set(pCallback callback)
{
m_callback = callback;
}
void _check()
{
GetInstance()->_set(&CClass::GetInstance()->set_reload);
}
private:
void static set_reload(void)
{
if(m_bReload == false)
{
m_bReload = true;
}
}
private:
static CClass* m_pInstance;
private:
bool static m_bReload;
};
Но стоит убрать объявление static в m_bReload и set_reload,как компилятор начинает ругаться illegal operation on bound member function :
typedef void(*pCallback)(void);
class CClass
{
private:
explicit CClass(void);
public:
~CClass()
{
m_pInstance = NULL;
}
static CClass* GetInstance()
{
if (!m_pInstance)
{
m_pInstance = new CClass();
}
return m_pInstance;
}
private:
void _set(pCallback callback)
{
m_callback = callback;
}
void _check()
{
GetInstance()->_set(&CClass::GetInstance()->set_reload); <- Error illegal operation on bound member function
}
private:
void set_reload(void)
{
if(m_bReload == false)
{
m_bReload = true;
}
}
private:
static CClass* m_pInstance;
private:
bool m_bReload;
};
Это потому что CClass - singletone (static CClass* m_pInstance)?