i tried to overload the operators as we did in linked list for taking input and printing output but i am not able to do it
here is my code https://ide.codingblocks.com/s/304091
Binary tree overloading input and output operator
in your input overloading function you are passing root pointer by value , instead pass by reference , also buildtree() returns root so you should do root=buildtree()
your code :-
istream& operator>>(istream &is , node*root){
buildTree(root);
return is;
}
correct code :-
istream& operator>>(istream &is , node*&root){
root=buildTree();
return is;
}
@jatinupadhyay786, as i mentioned earlier
it should be root=buildTree();
instead of buildTree(root)
(at line 143)
as you did’nt defined any function buildTree which take a node* parameter
correct code :- https://ide.codingblocks.com/s/304113