struct someClass;
typedef LPVOID (*pfCallback)(someClass* pThis,LPVOID);
struct someClass{
static CONST int m_xxx=0;
CArray <pfCallback> m_arr_pCallback;
LPVOID invoke(int idx,LPVOID parm);
int AddCallback(pfCallback pCallback);
};
LPVOID someClass::invoke(int idx,LPVOID parm)
{
return m_arr_pCallback[idx](this,parm);
}
int someClass::AddCallback(pfCallback pCallback)
{
return m_arr_pCallback.Add(pCallback);
}
LPVOID callbackfun(someClass* pThis,LPVOID)
{
printf( "%d/n ",pThis-> m_xxx);
return NULL;
}
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
// initialize MFC and print and error on failure
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
// TODO: change error code to suit your needs
_tprintf(_T("Fatal Error: MFC initialization failed/n"));
nRetCode = 1;
}
else
{
// TODO: code your application's behavior here.
}
someClass s;
s.invoke(s.AddCallback(callbackfun),NULL);
return nRetCode;
}