我在一个名为的类中定义了一个公共模板函数EventDispatcher
:
public:
template <class className> void AddEventListener ( className* );
该函数实现如下:
template <class className>
void EventDispatcher::AddEventListener ( className* ptr )
{
};
然后在某个班级中,我创建了Timer
一个孩子的实例EventDispatcher
并调用AddEventListener
:
timer->AddEventListener ( this );
在我得到一个错误之后
/tmp/ccjRF7sK.o: In function `AirHockeyServer::AirHockeyServer()':
AirHockeyServer.cpp:(.text+0xa5): undefined reference to `void EventDispatcher::AddEventListener<AirHockeyServer>(AirHockeyServer*)'
/tmp/ccjRF7sK.o: In function `AirHockeyServer::AirHockeyServer()':
AirHockeyServer.cpp:(.text+0x187): undefined reference to `void EventDispatcher::AddEventListener<AirHockeyServer>(AirHockeyServer*)'
collect2: ld returned 1 exit status