When do you need to use an & before the operator declaration?
Example:
class ClassName {
public:
// Some constructor here..
ClassName operator+(...)
ClassName operator*(...)
ClassName &operator+=(...) < has an &
ClassName operator==(...)
ClassName &operator<<(...) < has an &
private:
// Some member variables here..
}
When you want to distinguish a postfix and prefix i++ or ++i you use an &
ClassName &operator++()
ClassName operator++(int)
But when do you use an & for the other operator overload functions? Is there some kind of rule or has it something to do with the memory?