我写了这段代码,但编译器给我一个错误,不知道为什么:S 所以我想知道你可以帮助我: 这是一个简单的线程实现的抽象类:
#ifndef THREAD_H
#define THREAD_H
#include <pthread.h>
class Thread {
public:
void start();
inline pthread_t getThread() const{
return _thread;
}
private:
pthread_t _thread;
inline static void* callRun(void* pObject){
((Thread*)pObject)->run();
return (void*)0;
}
protected:
virtual void* run();
};
#endif /* THREAD_H */
源代码是:
#include "Thread.h"
void Thread::start(){
pthread_attr_t attrib;
pthread_attr_init(&attrib);
pthread_attr_setdetachstate(&attrib, PTHREAD_CREATE_JOINABLE);
pthread_create(&_thread, &attrib, callRun, (void*)this);
pthread_attr_destroy(&attrib);
}
PlayersManager类继承自Thread
#ifndef PLAYERMANAGER_H
#define PLAYERMANAGER_H
#include "Thread.h"
class PlayersManager : public Thread {
private:
void movePlayers();
void checkPlayers();
void* run();
};
#endif /* PLAYERMANAGER_H */
但是我得到了下一个编译错误: build / Debug / GNU-Linux-x86 / PlayersManager.o :(。rodata._ZTI14PlayersManager [_ZTI14PlayersManager] + 0x8):未定义引用`typeinfo for Thread'
知道发生了什么?感谢。