请大虾们帮忙修改下,谢谢
#include<iostream.h>
template<class T>
struct Node
{
T data;
Node *next;
};
template<class T>
class LinkList
{
public:
LinkList();
LinkList(T [],int);
void Count(T);
private:
Node *first;
};
template<class T>
LinkList<T>::LinkList(T a[],int n)
{
Node *first=new Node;
Node *r=NULL;
r=first;
for(int i=0;i<n;i++)
{
Node *s=new Node;
s->data=a[i];
r->next=s;
r=s;
}
r->next = 0;
}
template<class T>
void LinkList<T>::Count(T x)
{
Node *p=first;
int count=0;
while(p->next)
{
if(p->data>x)
count++;
p=p->next;
}
cout<<count<<endl;
}
void main()
{
int n1;
cout<<"输入A的个数:n1=";
cin>>n1;
int *a;
a=new int[n1];
cout<<"\t输入A的数:";
for(int i=0; i<n1; i++)
cin>>a[i];
LinkList<int> A(a,n1);
int X;
cout<<"\t输入要比较的数X:";
cin>>X;
cout<<"比X大的数个个数为:";
A.Count(X);
}
运行时::\编程\C++\自编\001\001.cpp(21) : error C2955: 'Node' : use of class template requires template argument list
E:\编程\C++\自编\001\001.cpp(7) : see declaration of 'Node'
E:\编程\C++\自编\001\001.cpp(63) : while compiling class-template member function '__thiscall LinkList<int>::LinkList<int>(int [],int)'
E:\编程\C++\自编\001\001.cpp(21) : error C2955: 'Node' : use of class template requires template argument list
E:\编程\C++\自编\001\001.cpp(7) : see declaration of 'Node'
E:\编程\C++\自编\001\001.cpp(63) : while compiling class-template member function '__thiscall LinkList<int>::LinkList<int>(int [],int)'
E:\编程\C++\自编\001\001.cpp(21) : error C2512: 'Node' : no appropriate default constructor available
E:\编程\C++\自编\001\001.cpp(63) : while compiling class-template member function '__thiscall LinkList<int>::LinkList<int>(int [],int)'
E:\编程\C++\自编\001\001.cpp(26) : error C2955: 'Node' : use of class template requires template argument list
E:\编程\C++\自编\001\001.cpp(7) : see declaration of 'Node'
E:\编程\C++\自编\001\001.cpp(63) : while compiling class-template member function '__thiscall LinkList<int>::LinkList<int>(int [],int)'
E:\编程\C++\自编\001\001.cpp(26) : error C2955: 'Node' : use of class template requires template argument list
E:\编程\C++\自编\001\001.cpp(7) : see declaration of 'Node'
E:\编程\C++\自编\001\001.cpp(63) : while compiling class-template member function '__thiscall LinkList<int>::LinkList<int>(int [],int)'
E:\编程\C++\自编\001\001.cpp(26) : error C2512: 'Node' : no appropriate default constructor available
E:\编程\C++\自编\001\001.cpp(63) : while compiling class-template member function '__thiscall LinkList<int>::LinkList<int>(int [],int)'
E:\编程\C++\自编\001\001.cpp(27) : fatal error C1903: unable to recover from previous error(s); stopping compilation
E:\编程\C++\自编\001\001.cpp(63) : while compiling class-template member function '__thiscall LinkList<int>::LinkList<int>(int [],int)'
Error executing cl.exe.
001.obj - 7 error(s), 0 warning(s)