// 头文件
# include<string.h>
//forward declaration
template<class type>
class List;
//Item template definition
template<class type>
class Item
{
public:
friend List<type>;
Item();
Item(const type &);
private:
type data;
Item<type> * next;
};
//Constructor
template<class type>
Item<type>::Item():next(0){}
//Constructor
template<class type>
Item<type>::Item(const type & N):
data(N),next(0){}
template<class type>
class List
{
public:
List();//Destructor
bool IsEmpty();
void append();
void acquire();
void remove();
void print();
void modefy();
private:
Item<type> * Head, * End;
};
template<class type>
List<type>::List()
{
Head=NULL;
End=NULL;
}
template <class type>
void List<type>::acquire()
{
char response;
int cnt(0);
cout<<"请选择a.按姓名查询 b.按电话号码查询...";
cin>>response;
switch(response)
{
case 'a':
cin.ignore(80,'\n');
cout<<"请输入姓名:";
char nam[15];
cin.getline(nam,strlen(nam));
if(IsEmpty())
cout<<"没有记录系统为空!";
else
{
Item<type> * pt=Head;
while(pt)
{
if((pt->data).IsThisName(nam))
{
(pt->data).print();
cnt++;
}
pt=pt->next;
}
}
cout<<"共找到"<<cnt<<"个"<<"要查找的对象";
break;
case 'b':
cout<<"请输入电话号码:";
char pho[18];
cin.ignore(80,'\n');
cin.getline(pho,strlen(pho));
if(IsEmpty())
cout<<"没有记录系统为空!";
else
{
Item<type> * pt=Head;
while(pt)
{
if((pt->data).IsThisPho(pho))
{
(pt->data).print();
}
pt=pt->next;
}
}
break;
}
}
template <class type>
void List<type>::remove()
{
char response;
cout<<"请选择你删除所选的方式 a.通过姓名b.通过电话号码..";
cin>>response;