have assignment operators return a reference to *this
in built in types...assignment returns a reference to its left hand operand....so you wanna follow the convention
it applies to all operators not just assignment
class widget {
public:
widget& operator+=(const widget& rhs)
{...
return *this);
}
widget& operator=(int rhs)
{
....
return *this ;
}
};
unless you have a good reason for doing things differently, dont.
things to remember:
have assignement operator a reference to *this
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment