Template <class type> class Treeiterator { Public: Treeiterator ( const binarytree<type>& btree): T (Btree), current (NULL) {} virtual ~treeiterator () {} Virtual void A () = 0; Place first position as current position Virtual void operator+ + () = 0; Current position into a BOOL operator+ () const { return current!= NULL;} Determine if it is a valid location in the tree Const type& operator() () const; Returns the value that the current position refers to protected: Binarytree<type> T; Const bintreenode<type>* current; Private: Treeiterator ( const treeiterator&) {}//Copy Construction treeiterator& operator= ( const Treeiterator &) const; assigning values }; Sequence Cursor class Template <class type> class Postorderiter: public Treeiterator<type> { using treeiterator<type>::t; using treeiterator<type>::current; in GCC , these two base class variables need to be qualified, otherwise it is impossible to compile (seemingly unreasonable thing, is the C + + standard has changed.) ) // C + + There seems to be no such practice in the standards, and there is no mention in the books related to this . Public: Postorderiter ( const binarytree<type>& BT); ~postorderiter () {} void A (); Locate the first node in the sequence void operator+ + (); Locate the next node in the order protected: stack< stknode<type> > St; Recursive work stack for traversal }; Template <class type> Postorderiter<type>::P ostorderiter ( const binarytree<type>& BT): treeiterator<type> (BT) { St. Push (Stknode<type> (T.getroot ())); In this function, you must use the TREEITERATOR<TYPE>::T qualification to correctly reference T |