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.
'<<' is a binary operator. It takes an ostream object as its left operand and (in this case) a Box object as its right operand. If the '<<' operator function was declared as a member of Box, you would probably do this:
Box It!
You are viewing a single comment's thread. Return to all comments →
'<<' is a binary operator. It takes an ostream object as its left operand and (in this case) a Box object as its right operand. If the '<<' operator function was declared as a member of Box, you would probably do this:
This function expects a Box object as its left (invoking) operand and an ostream object as its right operand. So when you write
The two objects 'cout' and 'NewBox' are passed in the wrong order.
Friend functions, on the other hand, are not invoked by an object of the class to which they are friended. Hence, you may write:
and the objects 'cout' and 'NewBox' are passed in the correct order.