Code Fragment: EulerTour1



template <typename BinaryTree>
class EulerTour {
protected:
  typedef typename BinaryTree::Position Position;	// position in the tree
  const BinaryTree* tree;				// pointer to the tree
  // ... (insert TraversalResult here)
public:
  void initialize(const BinaryTree& T) 			// initialize
    { tree = &T; }
protected:                                              // local utilities
  int eulerTour(const Position& v) const;		// perform the Euler tour
					// functions to be redefined by subclasses
  virtual void visitExternal  (const Position& v, TraversalResult& r) const {}
  virtual void visitLeft      (const Position& v, TraversalResult& r) const {}
  virtual void visitBelow     (const Position& v, TraversalResult& r) const {}
  virtual void visitRight     (const Position& v, TraversalResult& r) const {}
  TraversalResult initResult() const { return TraversalResult(); }
  int result(const TraversalResult& r) const { return r.finalResult; }
};