class test
{
public:
int i = 0;
test& operator+=(const test &rhs)
{
i += rhs.i;
return *this;
}
};
int main()
{
test t;
test rhs;
rhs.i = 10;
// what's the difference betwen these 2?
t.operator+=(rhs);
t += rhs;
}
Is there any difference between t.operator+=(rhs); and t += rhs; here? I've always used the latter, and have never thought much about the former. Is there any advantage to using the former over the latter?