假设我有一个类,比如
class c {
// ...
void *print(void *){ cout << "Hello"; }
}
然后我有一个 c 的向量
vector<c> classes; pthread_t t1;
classes.push_back(c());
classes.push_back(c());
现在,我想在 c.print();
上创建一个线程
下面是我遇到的问题:
pthread_create(&t1, NULL, &c[0].print, NULL);
错误输出: 无法将‘ void * (tree _ item: : *)(void *)’转换为‘ void * (*)(void *)’的参数‘3’到‘ int pthread _ create (pthread _ t * ,const Pthread _ attr _ t * ,void * (*)(void *) ,void *)’