I'm learning C++, my background has been Java up to this point.
I have a question about friend functions as they relate to operator overloading. I understand the overloading side of things when it comes to class functions. For example, you can combine operands of different types so long as the leftmost one is of the class type, ie: someObj + 2.5, but you can't do 2.5 + someObj since C++ can't translate that into a function call.
Where I get screwed up is the friend functions. What's the need for it? Can't you just overload the operator again using function overloading for something like this?:
I have a question about friend functions as they relate to operator overloading. I understand the overloading side of things when it comes to class functions. For example, you can combine operands of different types so long as the leftmost one is of the class type, ie: someObj + 2.5, but you can't do 2.5 + someObj since C++ can't translate that into a function call.
Where I get screwed up is the friend functions. What's the need for it? Can't you just overload the operator again using function overloading for something like this?:
