Recursive Implementations 4: Traverse without Iterators?
protected:
template < class F > // function class
static void RTraverse (Node* n, F f)
// classic inorder traversal; apply function object f to each element
{
if (n == 0) return;
RTraverse(n->lchild_, f);
f(n); // function object call
RTraverse(n->rchild_, f);
}
...
public:
template < class F >
void Traverse (F f) { RTraverse(root_,f); }
...