... struct StringTreeNode { string data; StringTreeNode * left, * right; StringTreeNode(string s): data(s), left(NULL), right(NULL) { } }; void insert(StringTreeNode * & t, string s) { if (t==NULL) t = new StringTreeNode(s); else if (s <= t->data) insert(t->left, s); else insert(t->right, s); } bool find(StringTreeNode * t, string s) { string ans; if (t==NULL) return 0; else if (s == t->data) return 1; else if (s < t->data) return find(t->left, s); else return find(t->right, s); } void print(StringTreeNode * t) { if (t==NULL) return; print(t->left); cout << t->data << endl; print(t->right); } struct StringTree { StringTreeNode * it; StringTree(void) { it=NULL; } bool isempty(void) { return it!=NULL; } void insert(string s) { insert(it, s); } bool find(string s) { return find(it, s); } void print(void) { print(it); } }; void main(void) { cout << "enter: ...etc...\n"; StringTree tree; while (1) { cout << "> "; string command; cin >> command; if (command=="i") { string operand; cin >> operand; tree.insert(operand); cout << operand << " inserted\n"; } else if (command=="f") { string operand; cin >> operand; int found = tree.find(operand); cout << operand << ( found ? " present" : " not found" ) << "\n"; } else if (command=="p") { tree.print(); } ... etc etc