If the operation modifies the state of the class object, it operates on, it must be a member function, not a friend function Thus all operator such as =, *=, +=, etc are naturally defined as member functions not friend functions Conversely, if the operator does not modify any of its operands,but needs only a representation of the object, it does not have to be a member function and often less confusing.This is the reason why binary operators are often implemented as friend functions such as + , *, -, etc..
Becaus, Friend functions do not have a "this" pointer
obj1 = obj2; Operator "=" can be overloaded either by the member function or by the friend operator function.
In case of the friend function, the obj1 and obj2 are should be from the different classes. If they are from the same class, the compilation error will occur. We can't use the "this" pointer in the friend function since it is not the member function of the class.
So,
If both objects are from the same class it is better to for operator function (operator=) as member function.
If the objects are from the different class, then the operator function as friend function is advisable.