我想构建一个可以隐藏线程创建的“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