Assume that I have the following basic class where I want to overload operator+:
class foo {
private:
arbitrary datatype
public:
foo() { set private data; };
virtual ~foo() {};
};
I've always used this format:
foo operator+( const foo &rhs );
However, I've recently stumbled onto some code where the person exclusively used:
friend foo operator+( const foo &lhs, const foo &rhs );
So, is it standard to use one version over the other? Are there situations where you would be forced into one version (This is only for adding the same object types)? I'm not familiar with assembly language, but would the compiler convert these into the same list of instructions (This question is obviously dependent on answers to the first 2)?