回复 4楼 apull
是不是这样写啊?
#include <iostream>
using namespace std;
template <class T>
class SeqList
{
public:
SeqList(T data[Maxsize],int n);
private:
int length;
}
template <class T>
SeqList:: SeqList(T a[], int n)
{
if (n>MaxSize) throw "参数非法";
for (i=0; i<n; i++)
data[i]=a[i];
length=n;
}
int main{
int a[i]={1,2,3,4,5};
SeqList seqlist1;
cout<<seqlist1.length<<endl;
SeqList seqlist2(T a[],int n);
try{
if (n>MaxSize);
}
catch "参数非法";
cout<<data[i]<<endl;
cout<<seqlist2.length<<endl;
}