Doubt in operator overloading

Please refer this - https://ide.codingblocks.com/s/422584

Please share the complete code, if possible.

Please explain me how to do operator overloading, how to take input using cin >> root. Also, please help me out with the function required inside operator overloading.

Hey @gambhirrahul0 you knew about istream & ostream you just have to overload it with build function of linked list. If you didn’t understand a specific part then let me know will help you accordingly.

I didn’t understand that overloading part and how to overload it to make line 151 & 155 work? Please help me out with that part & explanation. Thanks in advance.

First see this code, this is how we do operator overloading.


Now whenever you will use >> , compiler will call the build function to take input like a linked list.
And whenever you will use <<, compiler will call the print function to print output like a linked list.
Also we are returning their object becuase, ostream class has protected constructors due to which we are not allowed to create any new object that is why u will always see & operator(by using this operator we pass same object instead of creating its copy) with ostream and istream class.

return is;
return os;

If have any issue in this, ask it here.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.