Trying to overload << in a templated Binary Tree
So that if I have a binary tree:
And there have been more numbers inserted I can just say:
BinaryTree<int> *t = new BinaryTree<int>(5);
I have overloaded this operator before, but never with templates, so I am unsure where I should start.
Here is my BinaryTree class:
I believe the function should be something like this:
template <class T>
BinaryTree<T>* insert(T, BinaryTree<T>*);
void inorder(BinaryTree<T>*); //prints using inorder traversal
I know you can't put << or >> overloaded functions as a member function, so does this not require a prototype, or just put it outside of the class and above the implementation?
friend ostream& operator<< <>(ostream&, const BinaryTree<T>&)
Hope this makes sense, thanks.
*EDIT* Actually, I am supposed to make it a friend function, so I would put it in the class