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.
The operators ‘<<' and '<<' are called like 'cout << ob1' and 'cin << ob1'. So if we want to make them a member method, then they must be made members of ostream and istream classes, which is not a good option most of the time. Therefore, these operators are overloaded as global functions with two parameters, cout and object of user defined class
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 →
The operators ‘<<' and '<<' are called like 'cout << ob1' and 'cin << ob1'. So if we want to make them a member method, then they must be made members of ostream and istream classes, which is not a good option most of the time. Therefore, these operators are overloaded as global functions with two parameters, cout and object of user defined class