诚求教模板问题~~拜托了
//===========//f1406.cpp
//使用类模板
//===============
#include<iostream>
using namespace std;
//-----------------------
template<typename T>
struct Node
{
Node(T& d):c(d),next(0),pref(0){}
T c;
Node *next,*pref;
};//---------------------------
template<typename T>
class List
{
Node<T> *first,*last;
public:
List();
void add(T& c);
void remove(T& c);
Node<T>* find(T& c);
void print();
~List();
};//----------------------------
template<typename T>
List<T>::List():first(0),last(0){}
//--------------------------------
template<typename T>
void List<T>::add(T& n)
{
Node<T>* p=new Node<T>(n);
p->next=first;
first=p;
(last?p->next->prev:last)=p;
}//-----------------------------------
template<typename T>
void List<T>::remove(T& n)
{
if(!(Node<T>* p=find(n))) return; //=????
(p->next?p->next->prev:last)=p->prev;
(p->prev?p->prev->next:first)=p->next;
delete p;
}//-------------------------------------
template<typename T>
Node<T>* List<T>::find(T& n)
{
for(Node<T>* p=first;p;p=p->next)
if(p->c==n) return p;
return 0;
}//--------------------------------------
template<typename T>
List<T>::~List()
{
for(Node<T>* p=first;p;delete p)
first=first->next;
}//--------------------------------------
template<typename T>
void List<T>::print()
{
for(Node<T>* p=first;p;p=p->next)
cout<<p->c<<" ";
cout<<endl;
}//--------------------------------------
int main()
{
List<double> dList;
dList.add(3.6);
dList.add(5.8);
dList.print();
List<int> iList;
iList.add(5);
iList.add(8);
iList.print();
}
'add' : cannot convert parameter 1 from 'const double' to 'double &'???