Why cant we overload assignment operator using a friend function?
Please help??
Thanks,
comwizz.
comwizz 0 Light Poster
Recommended Answers
Jump to Post>operator= can only be a member function.
Correct.>It is intimately connected to the object on the left side of the =.
Yes, but not so intimately (ie. constructor or destructor) that a non-member function is completely illogical. You could, if C++ allowed it, do this, and nobody would …
Jump to Post>So why not use the assignment operator overloading as a friend function
>by declaring and defining it above other functions
Indeed, why not? Just make sure that you get it right for any possible combination of functions and declarations in any number and combination of source files. And also keep …
All 6 Replies
SpS 34 Posting Pro
comwizz 0 Light Poster
Narue 5,707 Bad Cop Team Colleague
comwizz 0 Light Poster
Narue 5,707 Bad Cop Team Colleague
SpS 34 Posting Pro
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.