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.