By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,906 Members | 1,416 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,906 IT Pros & Developers. It's quick & easy.

overloading assignment operator

P: 2
is it true that you cannot overload the assignment operator through a friend function?
please give a reason for your answer.
May 31 '07 #1
Share this Question
Share on Google+
4 Replies


sicarie
Expert Mod 2.5K+
P: 4,677
is it true that you cannot overload the assignment operator through a friend function?
please give a reason for your answer.
What do you think? Have you tried writing a program that tries to do this?
May 31 '07 #2

100+
P: 208
is it true that you cannot overload the assignment operator through a friend function?
please give a reason for your answer.
Sounds like a homework / test question
May 31 '07 #3

weaknessforcats
Expert Mod 5K+
P: 9,197
The answer is: Yes.

A friend function is just a regular global function that has persomssion to access the class private data members. This has nothing to do with operator overloading.

An assignment operator inside a class has the "this" pointer as the first argument and a class object as the second argument. An assignment operator outside the class has two arguments. All overloading requires is that the function names be the same and the arguments are different.
May 31 '07 #4

P: 2
The answer is: Yes.

A friend function is just a regular global function that has persomssion to access the class private data members. This has nothing to do with operator overloading.

An assignment operator inside a class has the "this" pointer as the first argument and a class object as the second argument. An assignment operator outside the class has two arguments. All overloading requires is that the function names be the same and the arguments are different.
Thank you for your reply. i came across this question in one of the past exam papers that i was going thru. i could not find a satisfying reason to explain to myself. thanks once again.
Jun 1 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.