Compilation 未定义对'的引用;螺纹的类型信息';
我写了这段代码,但编译器给了我一个错误,不知道为什么:S 所以我想知道你能否帮我: 这是一个用于简单线程实现的抽象类:Compilation 未定义对'的引用;螺纹的类型信息';,compilation,undefined,typeinfo,Compilation,Undefined,Typeinfo,我写了这段代码,但编译器给了我一个错误,不知道为什么:S 所以我想知道你能否帮我: 这是一个用于简单线程实现的抽象类: #ifndef THREAD_H #define THREAD_H #include <pthread.h> class Thread { public: void start(); inline pthread_t getThread() const{ return _thread; } private: pt
#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 */
类PlayerManager继承自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.\u ZTI14PlayersManager[\u ZTI14PlayersManager]+0x8):未定义对“线程类型信息”的引用
知道发生了什么吗?谢谢。我解决了这个问题,只是将运行的方法从protected更改为public。我不知道为什么它以前不工作,我想是因为callRun方法,但不管怎样,它现在工作得很好XD。谢谢,这段代码是开源的。
#ifndef PLAYERMANAGER_H
#define PLAYERMANAGER_H
#include "Thread.h"
class PlayersManager : public Thread {
private:
void movePlayers();
void checkPlayers();
void* run();
};
#endif /* PLAYERMANAGER_H */