Link to home
Start Free TrialLog in
Avatar of LuckyLucks
LuckyLucks

asked on

returning a dereferenced pts in C++

A&
A::operator= (const A& a) {
    if (this == &a)
        return (*this); <----
}


Does the above make sense? shouldn't we be returning this and not *this?
SOLUTION
Avatar of Zoppo
Zoppo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of LuckyLucks
LuckyLucks

ASKER

actually let's revisit this.

A& would return the address of the object. *this the value. they are not the same.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Best split.
share pts and close.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
completed.
Good to hear that reopening the question helped you better understand the issue.