0001 template <typename T> //遍历Quadlist,对各节点依次实施visit操作 0002 void Quadlist<T>::traverse ( void ( *visit ) ( T& ) ) { //利用函数指针机制,只读或局部性修改 0003 QlistNodePosi(T) p = header; 0004 while ( ( p = p->succ ) != trailer ) visit ( p->data ); 0005 } 0006 0007 template <typename T> template <typename VST> //遍历Quadlist,对各节点依次实施visit操作 0008 void Quadlist<T>::traverse ( VST& visit ) { //利用函数对象机制,可全局性修改 0009 QlistNodePosi(T) p = header; 0010 while ( ( p = p->succ ) != trailer ) visit ( p->data ); 0011 }