// This is our old friend the list class. template class LNode { Etype value; LNode *next; // it is very important that X is passed by reference // otherwise a copy constructor is needed LNode(const Etype & X, LNode *n=NULL) { next=n; value=X; }; friend class List; }; template class List { LNode *head; LNode *current; const Etype nulltype; // a user specified value // that indicates a null value public: List() { current=head=NULL; }; List(const Etype & nt) : nulltype(nt) { current=head=NULL;}; Etype First() { current=head; return current ? current->value : nulltype;}; Etype operator++(); Etype operator()() { return current ? current->value : nulltype; }; void Insert(const Etype &); int Find(Etype); int IsCurrent() { return current ? 1: 0; }; }; template Etype List::operator++() { if (current) current=current->next; return current ? current->value : nulltype; } template void List::Insert(const Etype & X) { current=new LNode(X,head); head=current; } template int List::Find(Etype X) { current=head; while (current) { if (X==current->value) break; else current=current->next; } return (current!=NULL); }