April 9th, 2003, 07:26 PM
<< overloading of Binary Search Tree
I am attempted to overload the << operator for a binary search tree and have run into a snag. Does anyone have any ideas on how to accomplish this? Does anyone know of any examples or could someone provide one? In the end, I hope to be able to have the user choose the order to print the nodes (preorder/inorder/postorder).
Here are my class definitions for the search tree, in case they help.
friend class binarySearchTree;
int value; // Value store by the node
binarySearchNode * leftChild;
binarySearchNode * rightChild;
binarySearchNode * root;
int order; // Order of traversal
... // Omitted the member functions
friend ostream & operator << (ostream &, const binarySearchTree &);
I've tried to call a recursive member function from the operator << method, but have not been able to make it work myself. I hope someone can help me out. If anymore information is required, I would be happy to provide it. Thanks in advance for any help anyone may provide.