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.
friend function has access to private members of class.
Here to overload << operator , you need an instance of stream (ostream) which dont have access to l , b and h of Class Box . Using friend function enables the ostream instance to access private data members.
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 →
friend function has access to private members of class. Here to overload << operator , you need an instance of stream (ostream) which dont have access to l , b and h of Class Box . Using friend function enables the ostream instance to access private data members.