We had an assignment in school implementing a Matrix class that overloads all arithmetic operators. What I did was to (for example) define += as a member function, and then define + as a non-member function that uses += function (both in the same file, but + outside the class). The school staff did something similar, only they've declared '+' as a friend function (and also used the implementation of +=).
Since both implementation work perfectly, I am trying to understand what does a friend function gives me that a non member function does not? When should I prefer each over the other?
Thanks! Yotam