菜鸟求助!代码出现LNK2019错误

喜欢源码 喜欢源码 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
附带吗:
list.h

#include <iostream>
using namespace std;

const int max = 21;

template<class T>
class listSequence{
private:
T data[max];
int length;
int location;
int loc[max];
public:
listSequence();
listSequence(T data[],int num);
};
list.cpp


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

template<class T>
listSequence<T>::listSequence(){
for (int i = 0; i < max; i++)
data[i] = 0;
for (int m = 0; m < max; m++)
loc[m] = -1;
length = 0;
location = 0;
}

template<class T>
listSequence<T>::listSequence(T data[],int num){
if (num>max) throw "上溢!";
for (int i = 0; i < num; i++)
this.data[i] = data[i];
for (int m = 0; m < max; m++)
loc[m] = -1;
length = 0;
location = 0;
}

main.cpp

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

int main(int argc,char * argv[]){
listSequence<short> listS;
return 1;
}

错误 1 error LNK2019: 无法解析的外部符号 "public: __thiscall listSequence<short>::listSequence<short>(void)" (??0?$listSequence@F@@QAE@XZ),该符号在函数 _main 中被引用 D:\work\DataStruct\DataStruct\zone.obj DataStruct
...全文
评论 6
收藏 已收藏
分享
返回顶部
喜欢源码
C++ 语言 65,212 成员 250,513 内容