We can overload assignment operator as a normal function.But we can not overload assignment operator as friend function why?

Showing Answers 1 - 2 of 2 Answers

sumanjit

  • Sep 15th, 2005
 

If the operation modifies the state of the class object, it operates on, it must be a member function, not a friend fucntionThus all operator such as =, *=, +=, etc are naturally defined asmember functions not friend functionsConversely, if the operator does not modify any of its operands,but needs only a representation of the object, it does not have tobe a member function and often less confusing.This is the reason why binary operators are often implemented asfriend functions sunch as + , *, -, etc..

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions