... struct LittleNote { StringTree * tree; int position; LittleNote(void) { } LittleNote(StringTree * t, int pos): tree(t), position(pos) { } }; struct Enumeration { LittleNote stack[100]; int numinstack; bool nextisknown; string next; Enumeration(StringTree * t) { stack[0]=LittleNote(t,1); numinstack=1; nextisknown=false; next=""; } void push(LittleNote n) { stack[numinstack] = n; numinstack += 1; } LittleNote pop(void) { numinstack -= 1; return stack[numinstack]; } void preparenext(void) { while (numinstack>0) { LittleNote note = pop(); StringTree * t = note.tree; switch (note.position) { case 1: { if (t!=NULL) { push(LittleNote(t, 2)); push(LittleNote(t->left, 1)); } break; } case 2: { push(LittleNote(t->right, 1)); next = t->data; nextisknown = true; return; } } } nextisknown = false; } bool hasmore(void) { if (nextisknown) return true; preparenext(); return nextisknown; } string getnext(void) { if (!nextisknown) preparenext(); nextisknown = false; return next; } }; void print(StringTree * t) { Enumeration lister(t); while (lister.hasmore()) cout << lister.getnext() << "\n"; } ...