#include<iostream.h>
template <class Type>
class seqList
{
friend ostream & operator<<(ostream& ,const seqList&); //重载流输出运算符
friend istream & operator>>(istream&,seqList&); //重载流输入运算符
public:
seqList ( int MaxSize = defaultSize );
~seqList ( ) { delete [ ] data; }
int length ( ) const { return last+1; }
int find ( Type & x ) const;
int isIn ( Type & x );
int insert ( Type & x, int i );
int remove ( Type & x );
int next ( Type & x ) ;
int prior ( Type & x ) ;
int isEmpty ( ) { return last ==-1; }
int isFull ( ) { return last == MaxSize-1; }
Type get ( int i )
{
return i < 0 || i > last?NULL : data[i];
}
private:
Type *data; //顺序表存储数组
int maxSize; //最大允许长度
int last; //当前最后元素下标
};
////////////////////////////////////////////////////////////
#include<iostream.h>
#include"list.h"
template <class Type>
seqList<Type> :: seqList ( int sz )
{ //构造函数
if (sz>0)
{
maxSize = sz;
last = -1;
data = new Type[maxSize];
if ( data == NULL )
{
maxSize = 0;
last = -1;
return;
}
}
}
template <class Type>
int seqList<Type>::find ( Type & x ) const
{
//搜索函数:在表中从前向后顺序查找 x
int i = 0;
while ( i <= last && data[i] != x )
i++;
if ( i > last )
return -1;
else
return i;
}
template <class Type>
int seqList<Type>::insert ( Type & x, int i )
{//在表中第 i 个位置插入新元素 x
if ( i < 0 || i > last+1 || last == maxSize-1 )
return 0; //插入不成功
else
{
last++;
for ( int j = last; j > i; j-- )
data[j] = data[j -1];
data[i] = x;
return 1; //插入成功
}
}
template <class Type>
int seqList<Type>::remove ( Type & x )
{//在表中删除已有元素 x
int i = find (x); //在表中搜索 x
if ( i >= 0 )
{
last-- ;
for ( int j = i; j <= last; j++ )
data[j] = data[j+1];
return 1; //成功删除
}
return 0; //表中没有 x
}
template <class Type>
istream&operator>>(istream& input,seqList<Type> &a)//重载>>函数的实现
{
for(int i=0;i<a.maxSize;i++)
input>>a.date[i];
return input;
}
template <class Type>
ostream& operator<<(ostream &output,const seqList<Type> &a)//重载<<函数的实现
{
int i=0;
for(i=0;i<a.maxSize;i++)
{
output<<" "<<a.date[i];
}
output<<endl;
return output;
}
//////////////////////////////////////////////
#include<iostream.h>
#include"list.h"
template <class Type>
void Intersection ( seqList<Type> & LA,seqList<Type> & LB )
{
int i=0,j=0;
Type temp;
aLen=LA.length();
for(i=0;i<aLen;i++)
{
temp=A.get(i);
bLen=LB.length();
if(i==0)
{
LB.insert(temp,i);
}
else
{
for(j=0;j<bLen;)
{
if(temp>LB.get(j))
j++;
else
{
LB.insert(temp,j);
break;
}
}
}
}
}
template <class Type>
int main()
{
seqList A(5),B(5);
cout<<"please enter five number to initial A:\n";
cin>>A;
cout<<A<<endl;
Intersection (A,B);
cout<<"B:"<<B<<endl;
return 1;
}
为什么通不过阿 模版去掉就好了
提示错误
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/list.exe : fatal error LNK1120: 1 unresolved externals
谢谢