类模板问题,undefined reference与报错无法解析的外部符号

今天编写了一个双向循环链表,想做一个模板类就用模板写了,结果无限报错。

代码如下:

#ifndef _DoublyCircularList_H_
#define _DoublyCircularList_H_

#include "listNode.h"

//  双向循环链表类声明
template<typename Type>
class DoublyCircularList
{
private:
    ListNode<Type>* head;
    size_t          count;
public:
    DoublyCircularList(const size_t size);
//  DoublyCircularList(const DoublyCircularList& ano);
   ~DoublyCircularList();

    bool   insert_(const Type& data, const size_t pos);
//  bool   delete_(const size_t pos);
//  bool   update_(const Type& data, const size_t pos);
//  bool   search_(const size_t pos) const;

//  size_t getCount()   const;
//  Type   getData()    const;
//  void   printList()  const;
//  void   vprintList() const;
};

#endif
#include <iostream>
#include "doublyCircularList.h"
using namespace std;

//  双向循环链表类定义
//  构造函数,负责创建size个结点的双向链表
template<typename Type>
DoublyCircularList<Type>::DoublyCircularList(const size_t size)
{
    count = 0;
    //  创建头结点
    head = new ListNode<Type>;
    head->prev = head->next = head;
    //  插入size个结点
    Type x;
    cout << "-----Ready to construct DoublyCircularList-----" << endl;
    cout << "Please input " << size << " data:" << endl;
    for(size_t i = 0; i < size; ++i){
        cin >> x;
//      insert_(x, i);
    }
    cout << "-----Input data end-----" << endl << endl;
}

template<typename Type>
DoublyCircularList<Type>::~DoublyCircularList()
{

}
#include <iostream>
#include "doublyCircularList.h"
using namespace std;

int main()
{
    cout << "----DoublyCircularList----\n" << endl;
    DoublyCircularList<int> L1(6);

    getchar();

    return 0;
}

在DevC++上编译显示

...

undefined reference to DoublyCircularList< int>::DoublyCircularList(unsigned long long)

undefined reference to DoublyCircularList< int>::~DoublyCircularList()

...

在VS2008上显示error LNK2019: 无法解析的外部符号 "public: __thiscall DoublyCircularList::~DoublyCircularList(void)" (??1?$DoublyCircularList@H@@QAE@XZ),该符号在函数 _main 中被引用

...

error LNK2019: 无法解析的外部符号 "public: __thiscall DoublyCircularList::DoublyCircularList(unsigned int)" (??0?$DoublyCircularList@H@@QAE@I@Z),该符号在函数 _main 中被引用

...

实在没搞懂这是什么意思,求高手指点迷津,感激不尽

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问