We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
ostream is the class which handles the output for us. So for overloading the << operator, you need to have a parameter as ostream, we take it by referece since its a class type and also since the object value will change.
We are returning ostream& since if we are cascading we need the ostream object again to print the other stuff.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Box It!
You are viewing a single comment's thread. Return to all comments →
It is a bit difficult to explain so bare with me
ostream is the class which handles the output for us. So for overloading the << operator, you need to have a parameter as ostream, we take it by referece since its a class type and also since the object value will change.
We are returning ostream& since if we are cascading we need the ostream object again to print the other stuff.