friend function and operator overloading

hi my friend
why we can not use friend function to overload the "=" operator ?
tnx
Because the = operator must be a member
Hi Bazzy
Your answer is exactly my question : why = operator must be a memeber ?
Because operators are meant to keep their original meaning, this way you can overload operator = only as the implementor of the new type. This prevents overloading something like int &operator = ( int &, const MyType & ) which could change the meaning of expression using built-in types. If you want to make your new type to be on the right side of an assignment with some other type, you must overload a conversion operator and then use the other type's own operator =
Topic archived. No new replies allowed.