我有我的基類:C++:在基類模板方法
class UnitTestThread : public testing::Test
{
public:
/// purgeQueue()
template <typename T> void purgeQueue(const ___handle queue, T &data) const;
};
我的繼承類:
class HmiTest : public UnitTestThread
{
public:
// Sets up the test fixture.
virtual void SetUp();
// ...
}
void HmiTest::SetUp()
{
// By default , purge all the queues
CONTROL_ACTION_PARAM controlAction;
purgeQueue(ApplicationContext.queueControlActionsToThermostat, controlAction);
}
而且我有一個鏈接錯誤:
HmiTest.obj : error LNK2019: unresolved external symbol "public: void __thiscall UnitTestThread::purgeQueue<struct CONTROL_ACTION_PARAM>(void * const,struct CONTROL_ACTION_PARAM &)const " ([email protected][email protected]@@[email protected]@[email protected]@@Z) referenced in function "public: virtual void __thiscall HmiTest::SetUp(void)" ([email protected]@@UAEXXZ)
我不明白爲什麼...:-S
謝謝非常感謝你們的幫助!
凡'purgeQueue'定義? – StoryTeller
[爲什麼模板只能在頭文件中實現?](http://stackoverflow.com/questions/495021/why-can-templates-only-be-implemented-in-the-header-file) – Jarod42
@Anthony你需要接受一個答案。 –