我想構建一個可以隱藏線程創建的「IThread」類。子類實現「ThreadMain」方法,並自動調用它看起來像這樣:如何將void(__thiscall MyClass :: *)(void *)轉換爲void(__cdecl *)(void *)指針
class IThread
{
public:
void BeginThread();
virtual void ThreadMain(void *) PURE;
};
void IThread::BeginThread()
{
//Error : cannot convert"std::binder1st<_Fn2>" to "void (__cdecl *)(void *)"
m_ThreadHandle = _beginthread(
std::bind1st(std::mem_fun(&IThread::ThreadMain), this),
m_StackSize, NULL);
//Error : cannot convert void (__thiscall*)(void *) to void (__cdecl *)(void *)
m_ThreadHandle = _beginthread(&IThread::ThreadMain, m_StackSize, NULL);
}
我已經搜索周圍,無法弄清楚。有沒有人做過這樣的事情?或者我走錯路了? TIA
OP沒有使用搜索 – zabulus 2011-03-16 13:53:46