郁闷,学数据结构,照书抄都编译不过去,我还找不到错误,帮忙看一下
学习C++数据结构中的线性表,今天手勤快点,想把它写出来,可谁知道才写了点就编译不出来了
头文件:
#pragma once
template<class T>
class LinearList
{
public:
LinearList(int MaxListSize=10);
~LinearList();
bool IsEmpty(void);
private:
int iLength;
int iMaxSize;
T *tElement;
};
实现文件:
#include "StdAfx.h"
#include ".\linearlist.h"
template<class T>
LinearList<T>::LinearList(int MaxListSize)
{
iMaxSize=MaxListSize;
tElement=new T[iMaxSize];
iLength=0;
}
template<class T>
LinearList<T>::~LinearList()
{
}
template<class T>
bool LinearList<T>::IsEmpty(void)
{
return false;
}
Main函数:
// Main.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include "LinearList.h"
int main(int argc, _TCHAR* argv[])
{
LinearList<int> y(100);//一加这句编译时就有错误
return 0;
}
编译错误如下:
LinearList error LNK2019: 无法解析的外部符号 "public: __thiscall LinearList<int>::~LinearList<int>(void)" (??1?$LinearList@H@@QAE@XZ) ,该符号在函数 _main 中被引用
LinearList error LNK2019: 无法解析的外部符号 "public: __thiscall LinearList<int>::LinearList<int>(int)" (??0?$LinearList@H@@QAE@H@Z) ,该符号在函数 _main 中被引用
LinearList fatal error LNK1120: 2 个无法解析的外部命令