Please explain me the lines 168 - 175.
Thanks in advance.
Hey @gambhirrahul0
FAQ WHY PASSED BY REFERENCE?
If you overloaded an operator with one argument simply as ‘ostream’, what the compiler will do is that it will try to create a copy of that object when your function is called.
ostream and istream classes do not permit us to create new objects of them or create copies of them from existing objects. Hence you would get an error for this. The only option is to use the already instantiated objects like cout ( for ostream ) and cin ( for istream ) and pass them by reference to functions so no copies are created.
168-171 is used to overload cout<< operator
u will write cout<<head; some where and this will trigger
it receivers two args cout and head
172- 175 is used to overload cin>> operator
u will write cin>>head; some where and this will trigger
it also receives two args cin, and head
Thanks for the ans. I’ve dropped you a query over the chat, please check.
replied. . . . . . . . . . … . .
Thanks for clearing it.
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.