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.

class binarySearchNode
{
friend class binarySearchTree;

int value; // Value store by the node

binarySearchNode * leftChild;
binarySearchNode * rightChild;

BinarySearchNode(int val);
};


class binarySearchTree
{
binarySearchNode * root;
int order; // Order of traversal
public:
... // 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.