- 论坛徽章:
- 0
|
本帖最后由 zhanhorse 于 2014-02-18 12:55 编辑
线程函数pthread_create使用类的非静态成员函数,但编译的时候报错。
请大侠指点一下是模板类定义错误,还是调用模板类的时候有问题。谢谢!
定义模板类:
template <typename TYPE, void (TYPE::ReadCustTypePointFile)>
void* _thread_t(void* param)
{
TYPE* This = (TYPE*)param;
This->ReadCustTypePointFile();
return NULL;
}
class CustPoint
{
public:
void *ReadCustTypePointFile(void *SourFile);
}
CustPoint::CustPoint()
{
//调用线程函数
pthread_create(pthread_serv,NULL,_thread_t<CustPoint, CustPoint::ReadCustTypePointFile>,(void *)(&SourFile));
}
"CustPoint.cpp", line 453: error #2386: no instance of function template
"_thread_t" matches the required type
pthread_create(pthread_serv,NULL,_thread_t<CustPoint, CustPoint::ReadCustTypePointFile>,(void *)(&SourFile));
|
|