Why cant we overload assignment operator using a friend function?
Please help??
Thanks,
comwizz.
comwizz
0
Light Poster
Recommended Answers
Jump to PostWhy cant we overload assignment operator using a friend function?
operator=
can only be a member function. It is intimately connected to the object on the left side of the=
.If it was possible to define
operator=
globally, then you might attempt to …
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 …
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.