I was looking at the d3dx math .h and noticed that a difference between the "+" and "+=" operators:
D3DXVECTOR3& operator += ( CONST D3DXVECTOR3& ); D3DXVECTOR3 operator + ( CONST D3DXVECTOR3& ) const;
Why is it returning a reference in the case of a += operation and a copy in the case of + operation ?
I'm guessing in the first case it's modifying the vector on which you call the += operation, something like this:
this->_x += x; ... return *this;
and in the case of a + operation it would be doing something like this:
return D3DXVECTOR3(this->_x + x, this->_y + y, this->_z + z);
That being said, if that's what happens in the D3DXVECTOR3 implementation, why not return a reference in the case of + operation ?